Skip to content

Commit 1f03f49

Browse files
committed
simplify alias
1 parent 19d2c4e commit 1f03f49

File tree

1 file changed

+6
-87
lines changed

1 file changed

+6
-87
lines changed

R/coord-transform.R

Lines changed: 6 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
#' [scales::new_transform()] for list of transformations, and instructions
99
#' on how to create your own.
1010
#'
11+
#' The `coord_trans()` function is deprecated in favour of `coord_transform()`.
12+
#'
1113
#' @inheritParams coord_cartesian
1214
#' @param x,y Transformers for x and y axes or their names.
1315
#' @param limx,limy `r lifecycle::badge("deprecated")` use `xlim` and `ylim` instead.
16+
#' @param ... Arguments forwarded to `coord_transform()`.
1417
#' @seealso
1518
#' The `r link_book("coord transformations section", "coord#transformations-with-coord_trans")`
1619
#' @export
@@ -103,99 +106,15 @@ coord_transform <- function(x = "identity", y = "identity", xlim = NULL, ylim =
103106
)
104107
}
105108

106-
#' Transformed Cartesian coordinate system
107-
#'
108-
#' `r lifecycle::badge("deprecated")`
109-
#'
110-
#' `coord_trans()` is different to scale transformations in that it occurs after
111-
#' statistical transformation and will affect the visual appearance of geoms - there is
112-
#' no guarantee that straight lines will continue to be straight.
113-
#'
114-
#' Transformations only work with continuous values: see
115-
#' [scales::new_transform()] for list of transformations, and instructions
116-
#' on how to create your own.
117-
#'
118-
#' @inheritParams coord_cartesian
119-
#' @param x,y Transformers for x and y axes or their names.
120-
#' @param limx,limy `r lifecycle::badge("deprecated")` use `xlim` and `ylim` instead.
121-
#' @seealso
122-
#' The `r link_book("coord transformations section", "coord#transformations-with-coord_trans")`
109+
#' @rdname coord_transform
123110
#' @export
124-
#' @examples
125-
#' \donttest{
126-
#' # See ?geom_boxplot for other examples
127-
#'
128-
#' # Three ways of doing transformation in ggplot:
129-
#' # * by transforming the data
130-
#' ggplot(diamonds, aes(log10(carat), log10(price))) +
131-
#' geom_point()
132-
#' # * by transforming the scales
133-
#' ggplot(diamonds, aes(carat, price)) +
134-
#' geom_point() +
135-
#' scale_x_log10() +
136-
#' scale_y_log10()
137-
#' # * by transforming the coordinate system:
138-
#' ggplot(diamonds, aes(carat, price)) +
139-
#' geom_point() +
140-
#' coord_trans(x = "log10", y = "log10")
141-
#'
142-
#' # The difference between transforming the scales and
143-
#' # transforming the coordinate system is that scale
144-
#' # transformation occurs BEFORE statistics, and coordinate
145-
#' # transformation afterwards. Coordinate transformation also
146-
#' # changes the shape of geoms:
147-
#'
148-
#' d <- subset(diamonds, carat > 0.5)
149-
#'
150-
#' ggplot(d, aes(carat, price)) +
151-
#' geom_point() +
152-
#' geom_smooth(method = "lm") +
153-
#' scale_x_log10() +
154-
#' scale_y_log10()
155-
#'
156-
#' ggplot(d, aes(carat, price)) +
157-
#' geom_point() +
158-
#' geom_smooth(method = "lm") +
159-
#' coord_trans(x = "log10", y = "log10")
160-
#'
161-
#' # Here I used a subset of diamonds so that the smoothed line didn't
162-
#' # drop below zero, which obviously causes problems on the log-transformed
163-
#' # scale
164-
#'
165-
#' # With a combination of scale and coordinate transformation, it's
166-
#' # possible to do back-transformations:
167-
#' ggplot(diamonds, aes(carat, price)) +
168-
#' geom_point() +
169-
#' geom_smooth(method = "lm") +
170-
#' scale_x_log10() +
171-
#' scale_y_log10() +
172-
#' coord_trans(x = scales::transform_exp(10), y = scales::transform_exp(10))
173-
#'
174-
#' # cf.
175-
#' ggplot(diamonds, aes(carat, price)) +
176-
#' geom_point() +
177-
#' geom_smooth(method = "lm")
178-
#'
179-
#' # Also works with discrete scales
180-
#' set.seed(1)
181-
#' df <- data.frame(a = abs(rnorm(26)),letters)
182-
#' plot <- ggplot(df,aes(a,letters)) + geom_point()
183-
#'
184-
#' plot + coord_trans(x = "log10")
185-
#' plot + coord_trans(x = "sqrt")
186-
#' }
187-
coord_trans <- function(x = "identity", y = "identity", xlim = NULL, ylim = NULL,
188-
limx = deprecated(), limy = deprecated(), clip = "on", expand = TRUE) {
111+
coord_trans <- function(...) {
189112
deprecate_soft0(
190113
"3.5.2",
191114
"coord_trans()",
192115
"coord_transform()"
193116
)
194-
195-
coord_transform(
196-
x = x, y = y, xlim = xlim, ylim = ylim,
197-
limx = limx, limy = limy, clip = clip, expand = expand
198-
)
117+
coord_transform(...)
199118
}
200119

201120
#' @rdname ggplot2-ggproto

0 commit comments

Comments
 (0)