Skip to content

Deprecate limx and limy in coord_trans() #3056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
35 changes: 21 additions & 14 deletions R/coord-transform.r
Original file line number Diff line number Diff line change
Expand Up @@ -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()`].
Expand Down Expand Up @@ -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
)
}
Expand Down
9 changes: 5 additions & 4 deletions man/coord_trans.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.