From c5cb500945af45735802fb0073034406d10e4d63 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Fri, 4 Jan 2019 12:28:24 -0500 Subject: [PATCH 1/4] Deprecate `limx` and `limy` in `coord_trans()` --- NEWS.md | 3 +++ R/coord-transform.r | 4 ++-- man/coord_trans.Rd | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 313dc17df7..806cb2ea4e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # ggplot2 3.1.0.9000 +* `coord_trans()` now uses `xlim` and `ylim`; `limx` and `limy` are + deprecated (@billdenney). + * `geom_rug()` now works with `coord_flip()` (@has2k1, #2987). * Layers now have a new member function `setup_layer()` which is called at the diff --git a/R/coord-transform.r b/R/coord-transform.r index 237c9dbe1f..8ec5b3c6aa 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()`]. diff --git a/man/coord_trans.Rd b/man/coord_trans.Rd index 56b7282b34..f4967398eb 100644 --- a/man/coord_trans.Rd +++ b/man/coord_trans.Rd @@ -10,14 +10,15 @@ coord_trans(x = "identity", y = "identity", limx = NULL, \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{limx, limy}{Deprecated; use \code{xlim} and \code{ylim} instead.} \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{xlim, ylim}{limits for x and y axes.} } \description{ \code{coord_trans} is different to scale transformations in that it occurs after From 6f6ff3e2cf653fba21e5b8f0830aa01425d09b53 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Fri, 4 Jan 2019 12:45:20 -0500 Subject: [PATCH 2/4] Completion of intended changes for `limx` and `limy` --- R/coord-transform.r | 27 +++++++++++++++++---------- man/coord_trans.Rd | 8 ++++---- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/R/coord-transform.r b/R/coord-transform.r index 8ec5b3c6aa..0599c7632c 100644 --- a/R/coord-transform.r +++ b/R/coord-transform.r @@ -78,8 +78,8 @@ #' 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.") @@ -89,20 +89,27 @@ coord_trans <- function(x = "identity", y = "identity", limx = NULL, limy = NULL gg_dep("1.0.1", "`ytrans` arguments is deprecated; please use `y` instead.") y <- ytrans } + if (!missing(limx)) { + gg_dep("3.1.0", "`limx` arguments is deprecated; please use `xlim` instead.") + if (!is.null(xlim)) { + stop("Must not provie both `xlim` and `limx`; please use `xlim` only.") + } + xlim <- limx + } + if (!missing(limy)) { + gg_dep("3.1.0", "`limy` arguments is deprecated; please use `ylim` instead.") + if (!is.null(ylim)) { + stop("Must not provie 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 f4967398eb..d7c4925281 100644 --- a/man/coord_trans.Rd +++ b/man/coord_trans.Rd @@ -4,13 +4,13 @@ \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}{Deprecated; use \code{xlim} and \code{ylim} instead.} +\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"} @@ -18,7 +18,7 @@ means no. For details, please see \code{\link[=coord_cartesian]{coord_cartesian( \item{xtrans, ytrans}{Deprecated; use \code{x} and \code{y} instead.} -\item{xlim, ylim}{limits for x and y axes.} +\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 From 99ba64c606d46e07819877a0805f03ff4552467e Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Fri, 4 Jan 2019 16:12:38 -0500 Subject: [PATCH 3/4] Correct typo --- R/coord-transform.r | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/coord-transform.r b/R/coord-transform.r index 0599c7632c..314b47e2c6 100644 --- a/R/coord-transform.r +++ b/R/coord-transform.r @@ -92,14 +92,14 @@ coord_trans <- function(x = "identity", y = "identity", xlim = NULL, ylim = NULL if (!missing(limx)) { gg_dep("3.1.0", "`limx` arguments is deprecated; please use `xlim` instead.") if (!is.null(xlim)) { - stop("Must not provie both `xlim` and `limx`; please use `xlim` only.") + stop("Must not provide both `xlim` and `limx`; please use `xlim` only.") } xlim <- limx } if (!missing(limy)) { gg_dep("3.1.0", "`limy` arguments is deprecated; please use `ylim` instead.") if (!is.null(ylim)) { - stop("Must not provie both `ylim` and `limy`; please use `ylim` only.") + stop("Must not provide both `ylim` and `limy`; please use `ylim` only.") } ylim <- limy } From 9fa976dc9cba66610e566045ae4d1088bbe4a351 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Thu, 11 Apr 2019 09:21:42 -0400 Subject: [PATCH 4/4] Correct grammar in warnings and errors --- R/coord-transform.r | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/R/coord-transform.r b/R/coord-transform.r index 314b47e2c6..ecdafea896 100644 --- a/R/coord-transform.r +++ b/R/coord-transform.r @@ -82,24 +82,24 @@ coord_trans <- function(x = "identity", y = "identity", xlim = NULL, ylim = NULL 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", "`limx` arguments is deprecated; please use `xlim` instead.") + gg_dep("3.1.0", "The `limx` argument is deprecated; please use `xlim` instead.") if (!is.null(xlim)) { - stop("Must not provide both `xlim` and `limx`; please use `xlim` only.") + stop("You must not provide both `xlim` and `limx`; please use `xlim` only.") } xlim <- limx } if (!missing(limy)) { - gg_dep("3.1.0", "`limy` arguments is deprecated; please use `ylim` instead.") + gg_dep("3.1.0", "The `limy` argument is deprecated; please use `ylim` instead.") if (!is.null(ylim)) { - stop("Must not provide both `ylim` and `limy`; please use `ylim` only.") + stop("You must not provide both `ylim` and `limy`; please use `ylim` only.") } ylim <- limy }