Skip to content

Commit 4330f9b

Browse files
authored
Supersede a few things (#6449)
* Use `coord_radial()` in examples * move and merge docs to `coord_radial()` * slap a superseded badge on `coord_polar()` * supersede `expand_limits()` * sprinkle `signal_stage("superseded")` all over * mark `type` argument as superseded * supersede `facet_wrap(as.table)` * supersede `labs()` variants * fix dumb mistake
1 parent 9383d2a commit 4330f9b

15 files changed

+134
-120
lines changed

R/annotation-logticks.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ annotation_logticks <- function(base = 10, sides = "bl", outside = FALSE, scaled
9393
if (!is.null(color))
9494
colour <- color
9595

96+
lifecycle::signal_stage("superseded", "annotation_logticks()", "guide_axis_logticks()")
97+
9698
if (lifecycle::is_present(size)) {
9799
deprecate_soft0("3.5.0", I("Using the `size` aesthetic in this geom"), I("`linewidth`"))
98100
linewidth <- linewidth %||% size

R/coord-flip.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#' geom_area() +
5858
#' coord_flip()
5959
coord_flip <- function(xlim = NULL, ylim = NULL, expand = TRUE, clip = "on") {
60+
lifecycle::signal_stage("superseded", "coord_flip()")
6061
check_coord_limits(xlim)
6162
check_coord_limits(ylim)
6263
ggproto(NULL, CoordFlip,

R/coord-map.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ coord_map <- function(projection="mercator", ..., parameters = NULL, orientation
136136
} else {
137137
params <- parameters
138138
}
139-
139+
lifecycle::signal_stage("superseded", "coord_map()", "coord_sf()")
140140
check_coord_limits(xlim)
141141
check_coord_limits(ylim)
142142

R/coord-polar.R

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,9 @@
1-
#' Polar coordinates
2-
#'
3-
#' The polar coordinate system is most commonly used for pie charts, which
4-
#' are a stacked bar chart in polar coordinates. `coord_radial()` has extended
5-
#' options.
6-
#'
7-
#' @param theta variable to map angle to (`x` or `y`)
8-
#' @param start Offset of starting point from 12 o'clock in radians. Offset
9-
#' is applied clockwise or anticlockwise depending on value of `direction`.
10-
#' @param direction 1, clockwise; -1, anticlockwise
11-
#' @param clip Should drawing be clipped to the extent of the plot panel? A
12-
#' setting of `"on"` (the default) means yes, and a setting of `"off"`
13-
#' means no. For details, please see [`coord_cartesian()`].
1+
#' @rdname coord_radial
142
#' @export
15-
#' @seealso
16-
#' The `r link_book("polar coordinates section", "coord#polar-coordinates-with-coord_polar")`
17-
#' @examples
18-
#' # NOTE: Use these plots with caution - polar coordinates has
19-
#' # major perceptual problems. The main point of these examples is
20-
#' # to demonstrate how these common plots can be described in the
21-
#' # grammar. Use with EXTREME caution.
22-
#'
23-
#' # A pie chart = stacked bar chart + polar coordinates
24-
#' pie <- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) +
25-
#' geom_bar(width = 1)
26-
#' pie + coord_polar(theta = "y")
27-
#'
28-
#' \donttest{
29-
#'
30-
#' # A coxcomb plot = bar chart + polar coordinates
31-
#' cxc <- ggplot(mtcars, aes(x = factor(cyl))) +
32-
#' geom_bar(width = 1, colour = "black")
33-
#' cxc + coord_polar()
34-
#' # A new type of plot?
35-
#' cxc + coord_polar(theta = "y")
36-
#'
37-
#' # The bullseye chart
38-
#' pie + coord_polar()
39-
#'
40-
#' # Hadley's favourite pie chart
41-
#' df <- data.frame(
42-
#' variable = c("does not resemble", "resembles"),
43-
#' value = c(20, 80)
44-
#' )
45-
#' ggplot(df, aes(x = "", y = value, fill = variable)) +
46-
#' geom_col(width = 1) +
47-
#' scale_fill_manual(values = c("red", "yellow")) +
48-
#' coord_polar("y", start = pi / 3) +
49-
#' labs(title = "Pac man")
50-
#'
51-
#' # Windrose + doughnut plot
52-
#' if (require("ggplot2movies")) {
53-
#' movies$rrating <- cut_interval(movies$rating, length = 1)
54-
#' movies$budgetq <- cut_number(movies$budget, 4)
55-
#'
56-
#' doh <- ggplot(movies, aes(x = rrating, fill = budgetq))
57-
#'
58-
#' # Wind rose
59-
#' doh + geom_bar(width = 1) + coord_polar()
60-
#' # Race track plot
61-
#' doh + geom_bar(width = 0.9, position = "fill") + coord_polar(theta = "y")
62-
#' }
63-
#' }
643
coord_polar <- function(theta = "x", start = 0, direction = 1, clip = "on") {
654
theta <- arg_match0(theta, c("x", "y"))
665
r <- if (theta == "x") "y" else "x"
6+
lifecycle::signal_stage("superseded", "coord_polar()", "coord_radial()")
677

688
ggproto(NULL, CoordPolar,
699
theta = theta,

R/coord-radial.R

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1-
2-
#' @rdname coord_polar
1+
#' Polar coordinates
2+
#'
3+
#' The polar coordinate system is most commonly used for pie charts, which
4+
#' are a stacked bar chart in polar coordinates. \cr
5+
#' `r lifecycle::badge("superseded")`: `coord_polar()` has been in favour of
6+
#' `coord_radial()`.
37
#'
8+
#' @param theta variable to map angle to (`x` or `y`)
9+
#' @param start Offset of starting point from 12 o'clock in radians. Offset
10+
#' is applied clockwise or anticlockwise depending on value of `direction`.
11+
#' @param direction 1, clockwise; -1, anticlockwise
12+
#' @param clip Should drawing be clipped to the extent of the plot panel? A
13+
#' setting of `"on"` (the default) means yes, and a setting of `"off"`
14+
#' means no. For details, please see [`coord_cartesian()`].
415
#' @param end Position from 12 o'clock in radians where plot ends, to allow
516
#' for partial polar coordinates. The default, `NULL`, is set to
617
#' `start + 2 * pi`.
@@ -26,7 +37,7 @@
2637
#' (default) keep directions as is. `"theta"` reverses the angle and `"r"`
2738
#' reverses the radius. `"thetar"` reverses both the angle and the radius.
2839
#' @param r_axis_inside,rotate_angle `r lifecycle::badge("deprecated")`
29-
#'
40+
#' @export
3041
#' @note
3142
#' In `coord_radial()`, position guides can be defined by using
3243
#' `guides(r = ..., theta = ..., r.sec = ..., theta.sec = ...)`. Note that
@@ -35,8 +46,56 @@
3546
#' be used for the `theta` positions. Using the `theta.sec` position is only
3647
#' sensible when `inner.radius > 0`.
3748
#'
38-
#' @export
49+
#' @seealso
50+
#' The `r link_book("polar coordinates section", "coord#polar-coordinates-with-coord_polar")`
3951
#' @examples
52+
#' # NOTE: Use these plots with caution - polar coordinates has
53+
#' # major perceptual problems. The main point of these examples is
54+
#' # to demonstrate how these common plots can be described in the
55+
#' # grammar. Use with EXTREME caution.
56+
#'
57+
#' # A pie chart = stacked bar chart + polar coordinates
58+
#' pie <- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) +
59+
#' geom_bar(width = 1)
60+
#' pie + coord_radial(theta = "y", expand = FALSE)
61+
#'
62+
#' \donttest{
63+
#'
64+
#' # A coxcomb plot = bar chart + polar coordinates
65+
#' cxc <- ggplot(mtcars, aes(x = factor(cyl))) +
66+
#' geom_bar(width = 1, colour = "black")
67+
#' cxc + coord_radial(expand = FALSE)
68+
#' # A new type of plot?
69+
#' cxc + coord_radial(theta = "y", expand = FALSE)
70+
#'
71+
#' # The bullseye chart
72+
#' pie + coord_radial(expand = FALSE)
73+
#'
74+
#' # Hadley's favourite pie chart
75+
#' df <- data.frame(
76+
#' variable = c("does not resemble", "resembles"),
77+
#' value = c(20, 80)
78+
#' )
79+
#' ggplot(df, aes(x = "", y = value, fill = variable)) +
80+
#' geom_col(width = 1) +
81+
#' scale_fill_manual(values = c("red", "yellow")) +
82+
#' coord_radial("y", start = pi / 3, expand = FALSE) +
83+
#' labs(title = "Pac man")
84+
#'
85+
#' # Windrose + doughnut plot
86+
#' if (require("ggplot2movies")) {
87+
#' movies$rrating <- cut_interval(movies$rating, length = 1)
88+
#' movies$budgetq <- cut_number(movies$budget, 4)
89+
#'
90+
#' doh <- ggplot(movies, aes(x = rrating, fill = budgetq))
91+
#'
92+
#' # Wind rose
93+
#' doh + geom_bar(width = 1) + coord_radial(expand = FALSE)
94+
#' # Race track plot
95+
#' doh + geom_bar(width = 0.9, position = "fill") +
96+
#' coord_radial(theta = "y", expand = FALSE)
97+
#' }
98+
#' }
4099
#' # A partial polar plot
41100
#' ggplot(mtcars, aes(disp, mpg)) +
42101
#' geom_point() +
@@ -475,7 +534,7 @@ CoordRadial <- ggproto("CoordRadial", Coord,
475534
}
476535
)
477536

478-
view_scales_polar <- function(scale, theta = "x", coord_limits = NULL,
537+
view_scales_polar <- function(scale, theta = "x", coord_limits = NULL,
479538
expand = TRUE) {
480539

481540
aesthetic <- scale$aesthetics[1]

R/facet-wrap.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ NULL
4545
#' the exterior axes get labels, and the interior axes get none. When
4646
#' `"all_x"` or `"all_y"`, only draws the labels at the interior axes in the
4747
#' x- or y-direction respectively.
48+
#' @param as.table `r lifecycle::badge("superseded")` The `as.table` argument
49+
#' is now absorbed into the `dir` argument via the two letter options.
50+
#' If `TRUE`, the facets are laid out like a table with highest values at the
51+
#' bottom-right. If `FALSE`, the facets are laid out like a plot with the
52+
#' highest value at the top-right.
4853
#'
4954
#' @section Layer layout:
5055
#' The [`layer(layout)`][layer()] argument in context of `facet_wrap()` can take

R/labels.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,19 +200,26 @@ labs <- function(..., title = waiver(), subtitle = waiver(), caption = waiver(),
200200

201201
#' @rdname labs
202202
#' @export
203+
#' @description
204+
#' `r lifecycle::badge("superseded")`: `xlab()`, `ylab()` and `ggtitle()` are
205+
#' superseded. It is recommended to use the `labs(x, y, title, subtitle)`
206+
#' arguments instead.
203207
xlab <- function(label) {
208+
lifecycle::signal_stage("superseded", "xlab()", "labs(x)")
204209
labs(x = label)
205210
}
206211

207212
#' @rdname labs
208213
#' @export
209214
ylab <- function(label) {
215+
lifecycle::signal_stage("superseded", "ylab()", "labs(y)")
210216
labs(y = label)
211217
}
212218

213219
#' @rdname labs
214220
#' @export
215221
ggtitle <- function(label, subtitle = waiver()) {
222+
lifecycle::signal_stage("superseded", "ggtitle()", I("labs(title, subtitle)"))
216223
labs(title = label, subtitle = subtitle)
217224
}
218225

R/limits.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ limits.POSIXlt <- function(lims, var, call = caller_env()) {
159159

160160
#' Expand the plot limits, using data
161161
#'
162+
#' `r lifecycle::badge("superseded")`: It is recommended to pass a function to
163+
#' the `limits` argument in scales instead. For example:
164+
#' `scale_x_continuous(limits = ~range(.x, 0))` to include zero.\cr\cr
162165
#' Sometimes you may want to ensure limits include a single value, for all
163166
#' panels or all plots. This function is a thin wrapper around
164167
#' [geom_blank()] that makes it easy to add such values.
@@ -181,6 +184,8 @@ limits.POSIXlt <- function(lims, var, call = caller_env()) {
181184
expand_limits <- function(...) {
182185
data <- list2(...)
183186

187+
lifecycle::signal_stage("superseded", "expand_limits()")
188+
184189
# unpack data frame columns
185190
data_dfs <- vapply(data, is.data.frame, logical(1))
186191
data <- unlist(c(list(data[!data_dfs]), data[data_dfs]), recursive = FALSE)

R/scale-colour.R

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,13 @@
77
#' functions that assign discrete color bins to the continuous values
88
#' instead of using a continuous color spectrum.
99
#'
10-
#' All these colour scales use the [options()] mechanism to determine
11-
#' default settings. Continuous colour scales default to the values of the
12-
#' `ggplot2.continuous.colour` and `ggplot2.continuous.fill` options, and
13-
#' binned colour scales default to the values of the `ggplot2.binned.colour`
14-
#' and `ggplot2.binned.fill` options. These option values default to
15-
#' `"gradient"`, which means that the scale functions actually used are
16-
#' [scale_colour_gradient()]/[scale_fill_gradient()] for continuous scales and
17-
#' [scale_colour_steps()]/[scale_fill_steps()] for binned scales.
18-
#' Alternative option values are `"viridis"` or a different scale function.
19-
#' See description of the `type` argument for details.
20-
#'
21-
#' Note that the binned colour scales will use the settings of
22-
#' `ggplot2.continuous.colour` and `ggplot2.continuous.fill` as fallback,
23-
#' respectively, if `ggplot2.binned.colour` or `ggplot2.binned.fill` are
24-
#' not set.
10+
#' `r lifecycle::badge("superseded")`: The mechanism of setting defaults via
11+
#' [options()] is superseded by theme settings. The preferred method to change
12+
#' the default palette of scales is via the theme, for example:
13+
#' `theme(palette.colour.continuous = scales::pal_viridis())`. The
14+
#' `ggplot2.continuous.colour` and `ggplot2.continuous.fill` options could be
15+
#' used to set default continuous scales and `ggplot2.binned.colour` and
16+
#' `ggplot2.binned.fill` options to set default binned scales.
2517
#'
2618
#' These scale functions are meant to provide simple defaults. If
2719
#' you want to manually set the colors of a scale, consider using
@@ -35,7 +27,7 @@
3527
#' * a palette function that when called with a numeric vector with values
3628
#' between 0 and 1 returns the corresponding output values.
3729
#' @param ... Additional parameters passed on to the scale type
38-
#' @param type One of the following:
30+
#' @param type `r lifecycle::badge("superseded")` One of the following:
3931
#' * "gradient" (the default)
4032
#' * "viridis"
4133
#' * A function that returns a continuous colour scale.
@@ -173,9 +165,7 @@ scale_fill_binned <- function(..., palette = NULL, aesthetics = "fill", guide =
173165

174166
#' Discrete colour scales
175167
#'
176-
#' The default discrete colour scale. Defaults to [scale_fill_hue()]/[scale_fill_brewer()]
177-
#' unless `type` (which defaults to the `ggplot2.discrete.fill`/`ggplot2.discrete.colour` options)
178-
#' is specified.
168+
#' The default discrete colour scale.
179169
#'
180170
#' @param palette One of the following:
181171
#' * `NULL` for the default palette stored in the theme.
@@ -185,7 +175,9 @@ scale_fill_binned <- function(..., palette = NULL, aesthetics = "fill", guide =
185175
#' number of levels in the scale) returns the values that they should take.
186176
#' @param ... Additional parameters passed on to the scale type,
187177
#' @inheritParams discrete_scale
188-
#' @param type One of the following:
178+
#' @param type `r lifecycle::badge("superseded")` The preferred mechanism for
179+
#' setting the default palette is by using the theme. For example:
180+
#' `theme(palette.colour.discrete = "Okabe-Ito")`. One of the following:
189181
#' * A character vector of color codes. The codes are used for a 'manual' color
190182
#' scale as long as the number of codes exceeds the number of data levels
191183
#' (if there are more levels than codes, [scale_colour_hue()]/[scale_fill_hue()]

man/coord_polar.Rd renamed to man/coord_radial.Rd

Lines changed: 11 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/expand_limits.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/facet_wrap.Rd

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)