diff --git a/NEWS.md b/NEWS.md index 34a7d7bc17..3d903e85fb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # ggplot2 3.1.1.9000 +* `geom_rug()` now works with `coord_flip()` (@has2k1, #2987). This is a minor release with an emphasis on internal changes to make ggplot2 faster and more consistent. The few interface changes will only affect the aesthetics of the plot in minor ways, and will only potentially break code of @@ -116,6 +117,9 @@ core developer team. * `stat_bin()` now handles data with only one unique value (@yutannihilation #3047). +* `coord_trans()` now uses `xlim` and `ylim`; `limx` and `limy` are + deprecated (@billdenney). + # ggplot2 3.1.0 ## Breaking changes diff --git a/R/coord-transform.r b/R/coord-transform.r index 237c9dbe1f..ecdafea896 100644 --- a/R/coord-transform.r +++ b/R/coord-transform.r @@ -10,8 +10,8 @@ #' #' @param x,y transformers for x and y axes #' @param xtrans,ytrans Deprecated; use `x` and `y` instead. -#' @param limx,limy limits for x and y axes. (Named so for backward -#' compatibility) +#' @param xlim,ylim limits for x and y axes. +#' @param limx,limy Deprecated; use `xlim` and `ylim` instead. #' @param clip Should drawing be clipped to the extent of the plot panel? A #' setting of `"on"` (the default) means yes, and a setting of `"off"` #' means no. For details, please see [`coord_cartesian()`]. @@ -78,31 +78,38 @@ #' plot + coord_trans(x = "log10") #' plot + coord_trans(x = "sqrt") #' } -coord_trans <- function(x = "identity", y = "identity", limx = NULL, limy = NULL, clip = "on", - xtrans, ytrans) +coord_trans <- function(x = "identity", y = "identity", xlim = NULL, ylim = NULL, clip = "on", + xtrans, ytrans, limx, limy) { if (!missing(xtrans)) { - gg_dep("1.0.1", "`xtrans` arguments is deprecated; please use `x` instead.") + gg_dep("1.0.1", "The `xtrans` argument is deprecated; please use `x` instead.") x <- xtrans } if (!missing(ytrans)) { - gg_dep("1.0.1", "`ytrans` arguments is deprecated; please use `y` instead.") + gg_dep("1.0.1", "The `ytrans` argument is deprecated; please use `y` instead.") y <- ytrans } + if (!missing(limx)) { + gg_dep("3.1.0", "The `limx` argument is deprecated; please use `xlim` instead.") + if (!is.null(xlim)) { + stop("You must not provide both `xlim` and `limx`; please use `xlim` only.") + } + xlim <- limx + } + if (!missing(limy)) { + gg_dep("3.1.0", "The `limy` argument is deprecated; please use `ylim` instead.") + if (!is.null(ylim)) { + stop("You must not provide both `ylim` and `limy`; please use `ylim` only.") + } + ylim <- limy + } - # @kohske - # Now limits are implemented. - # But for backward compatibility, xlim -> limx, ylim -> ylim - # Because there are many examples such as - # > coord_trans(x = "log10", y = "log10") - # Maybe this is changed. if (is.character(x)) x <- as.trans(x) if (is.character(y)) y <- as.trans(y) - ggproto(NULL, CoordTrans, trans = list(x = x, y = y), - limits = list(x = limx, y = limy), + limits = list(x = xlim, y = ylim), clip = clip ) } diff --git a/man/coord_trans.Rd b/man/coord_trans.Rd index 56b7282b34..d7c4925281 100644 --- a/man/coord_trans.Rd +++ b/man/coord_trans.Rd @@ -4,20 +4,21 @@ \alias{coord_trans} \title{Transformed Cartesian coordinate system} \usage{ -coord_trans(x = "identity", y = "identity", limx = NULL, - limy = NULL, clip = "on", xtrans, ytrans) +coord_trans(x = "identity", y = "identity", xlim = NULL, + ylim = NULL, clip = "on", xtrans, ytrans, limx, limy) } \arguments{ \item{x, y}{transformers for x and y axes} -\item{limx, limy}{limits for x and y axes. (Named so for backward -compatibility)} +\item{xlim, ylim}{limits for x and y axes.} \item{clip}{Should drawing be clipped to the extent of the plot panel? A setting of \code{"on"} (the default) means yes, and a setting of \code{"off"} means no. For details, please see \code{\link[=coord_cartesian]{coord_cartesian()}}.} \item{xtrans, ytrans}{Deprecated; use \code{x} and \code{y} instead.} + +\item{limx, limy}{Deprecated; use \code{xlim} and \code{ylim} instead.} } \description{ \code{coord_trans} is different to scale transformations in that it occurs after