Skip to content

Commit 63125db

Browse files
authored
Release 3.4.0 (#5025)
1 parent a58b48c commit 63125db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+4903
-445
lines changed

DESCRIPTION

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: ggplot2
2-
Version: 3.3.6.9000
2+
Version: 3.4.0
33
Title: Create Elegant Data Visualisations Using the Grammar of Graphics
44
Authors@R: c(
55
person("Hadley", "Wickham", , "hadley@rstudio.com", role = "aut",
@@ -43,7 +43,7 @@ Imports:
4343
scales (>= 1.2.0),
4444
stats,
4545
tibble,
46-
vctrs (>= 0.4.1),
46+
vctrs (>= 0.5.0),
4747
withr (>= 2.5.0)
4848
Suggests:
4949
covr,
@@ -71,8 +71,6 @@ Suggests:
7171
testthat (>= 3.1.2),
7272
vdiffr (>= 1.0.0),
7373
xml2
74-
Remotes:
75-
r-lib/lifecycle
7674
Enhances:
7775
sp
7876
VignetteBuilder:

NAMESPACE

+22-26
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@ S3method("$",ggproto)
44
S3method("$",ggproto_parent)
55
S3method("$<-",uneval)
66
S3method("+",gg)
7+
S3method("[",mapped_discrete)
78
S3method("[",uneval)
9+
S3method("[<-",mapped_discrete)
810
S3method("[<-",uneval)
911
S3method("[[",ggproto)
1012
S3method("[[<-",uneval)
1113
S3method(.DollarNames,ggproto)
14+
S3method(as.data.frame,mapped_discrete)
1215
S3method(as.list,ggproto)
1316
S3method(autolayer,default)
1417
S3method(autoplot,default)
18+
S3method(c,mapped_discrete)
1519
S3method(drawDetails,zeroGrob)
1620
S3method(element_grob,element_blank)
1721
S3method(element_grob,element_line)
1822
S3method(element_grob,element_rect)
1923
S3method(element_grob,element_text)
20-
S3method(format,ggplot2_mapped_discrete)
2124
S3method(format,ggproto)
2225
S3method(format,ggproto_method)
2326
S3method(fortify,"NULL")
@@ -139,30 +142,24 @@ S3method(scale_type,sfc)
139142
S3method(single_value,default)
140143
S3method(single_value,factor)
141144
S3method(summary,ggplot)
142-
S3method(vec_arith,ggplot2_mapped_discrete)
143-
S3method(vec_arith.ggplot2_mapped_discrete,MISSING)
144-
S3method(vec_arith.ggplot2_mapped_discrete,default)
145-
S3method(vec_arith.ggplot2_mapped_discrete,ggplot2_mapped_discrete)
146-
S3method(vec_arith.ggplot2_mapped_discrete,numeric)
147-
S3method(vec_arith.numeric,ggplot2_mapped_discrete)
148-
S3method(vec_cast,character.ggplot2_mapped_discrete)
149-
S3method(vec_cast,double.ggplot2_mapped_discrete)
150-
S3method(vec_cast,factor.ggplot2_mapped_discrete)
151-
S3method(vec_cast,ggplot2_mapped_discrete.double)
152-
S3method(vec_cast,ggplot2_mapped_discrete.factor)
153-
S3method(vec_cast,ggplot2_mapped_discrete.ggplot2_mapped_discrete)
154-
S3method(vec_cast,ggplot2_mapped_discrete.integer)
155-
S3method(vec_cast,integer.ggplot2_mapped_discrete)
156-
S3method(vec_math,ggplot2_mapped_discrete)
157-
S3method(vec_ptype2,character.ggplot2_mapped_discrete)
158-
S3method(vec_ptype2,double.ggplot2_mapped_discrete)
159-
S3method(vec_ptype2,factor.ggplot2_mapped_discrete)
160-
S3method(vec_ptype2,ggplot2_mapped_discrete.character)
161-
S3method(vec_ptype2,ggplot2_mapped_discrete.double)
162-
S3method(vec_ptype2,ggplot2_mapped_discrete.factor)
163-
S3method(vec_ptype2,ggplot2_mapped_discrete.ggplot2_mapped_discrete)
164-
S3method(vec_ptype2,ggplot2_mapped_discrete.integer)
165-
S3method(vec_ptype2,integer.ggplot2_mapped_discrete)
145+
S3method(vec_cast,character.mapped_discrete)
146+
S3method(vec_cast,double.mapped_discrete)
147+
S3method(vec_cast,factor.mapped_discrete)
148+
S3method(vec_cast,integer.mapped_discrete)
149+
S3method(vec_cast,mapped_discrete.double)
150+
S3method(vec_cast,mapped_discrete.factor)
151+
S3method(vec_cast,mapped_discrete.integer)
152+
S3method(vec_cast,mapped_discrete.logical)
153+
S3method(vec_cast,mapped_discrete.mapped_discrete)
154+
S3method(vec_ptype2,character.mapped_discrete)
155+
S3method(vec_ptype2,double.mapped_discrete)
156+
S3method(vec_ptype2,factor.mapped_discrete)
157+
S3method(vec_ptype2,integer.mapped_discrete)
158+
S3method(vec_ptype2,mapped_discrete.character)
159+
S3method(vec_ptype2,mapped_discrete.double)
160+
S3method(vec_ptype2,mapped_discrete.factor)
161+
S3method(vec_ptype2,mapped_discrete.integer)
162+
S3method(vec_ptype2,mapped_discrete.mapped_discrete)
166163
S3method(widthDetails,titleGrob)
167164
S3method(widthDetails,zeroGrob)
168165
export("%+%")
@@ -691,7 +688,6 @@ export(update_geom_defaults)
691688
export(update_labels)
692689
export(update_stat_defaults)
693690
export(vars)
694-
export(vec_arith.ggplot2_mapped_discrete)
695691
export(waiver)
696692
export(wrap_dims)
697693
export(xlab)

NEWS.md

+80-47
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,64 @@
1-
# ggplot2 (development version)
1+
# ggplot2 3.4.0
2+
This is a minor release focusing on tightening up the internals and ironing out
3+
some inconsistencies in the API. The biggest change is the addition of the
4+
`linewidth` aesthetic that takes of sizing the width of any line from `size`.
5+
This change, while attempting to be as non-breaking as possible, has the
6+
potential to change the look of some of your plots.
7+
8+
Other notable changes is a complete redo of the error and warning messaging in
9+
ggplot2 using the cli package. Messaging is now better contextualised and it
10+
should be easier to identify which layer an error is coming from. Last, we have
11+
now made the switch to using the vctrs package internally which means that
12+
support for vctrs classes as variables should improve, along with some small
13+
gains in rendering speed.
214

15+
## Breaking changes
16+
17+
* A `linewidth` aesthetic has been introduced and supersedes the `size`
18+
aesthetic for scaling the width of lines in line based geoms. `size` will
19+
remain functioning but deprecated for these geoms and it is recommended to
20+
update all code to reflect the new aesthetic. For geoms that have _both_ point
21+
sizing and linewidth sizing (`geom_pointrange()` and `geom_sf`) `size` now
22+
**only** refers to sizing of points which can leads to a visual change in old
23+
code (@thomasp85, #3672)
24+
25+
* The default line width for polygons in `geom_sf()` have been decreased to 0.2
26+
to reflect that this is usually used for demarking borders where a thinner
27+
line is better suited. This change was made since we already induced a
28+
visual change in `geom_sf()` with the introduction of the `linewidth`
29+
aesthetic.
30+
331
* The dot-dot notation (`..var..`) and `stat()`, which have been superseded by
432
`after_stat()`, are now formally deprecated (@yutannihilation, #3693).
533

34+
* `qplot()` is now formally deprecated (@yutannihilation, #3956).
35+
36+
* `stage()` now properly refers to the values without scale transformations for
37+
the stage of `after_stat`. If your code requires the scaled version of the
38+
values for some reason, you have to apply the same transformation by yourself,
39+
e.g. `sqrt()` for `scale_{x,y}_sqrt()` (@yutannihilation and @teunbrand, #4155).
40+
41+
* Use `rlang::hash()` instead of `digest::digest()`. This update may lead to
42+
changes in the automatic sorting of legends. In order to enforce a specific
43+
legend order use the `order` argument in the guide. (@thomasp85, #4458)
44+
45+
* referring to `x` in backquoted expressions with `label_bquote()` is no longer
46+
possible.
47+
48+
* The `ticks.linewidth` and `frame.linewidth` parameters of `guide_colourbar()`
49+
are now multiplied with `.pt` like elsewhere in ggplot2. It can cause visual
50+
changes when these arguments are not the defaults and these changes can be
51+
restored to their previous behaviour by adding `/ .pt` (@teunbrand #4314).
52+
53+
* `scale_*_viridis_b()` now uses the full range of the viridis scales
54+
(@gregleleu, #4737)
55+
56+
## New features
57+
658
* `geom_col()` and `geom_bar()` gain a new `just` argument. This is set to `0.5`
759
by default; use `just = 0`/`just = 1` to place columns on the left/right
860
of the axis breaks.
961
(@wurli, #4899)
10-
11-
* Fix a bug in `position_jitter()` where infinity values were dropped (@javlon,
12-
#4790).
13-
14-
* `geom_linerange()` now respects the `na.rm` argument (#4927, @thomasp85)
15-
16-
* Improve the support for `guide_axis()` on `coord_trans()` (@yutannihilation, #3959)
1762

1863
* `geom_density()` and `stat_density()` now support `bounds` argument
1964
to estimate density with boundary correction (@echasnovski, #4013).
@@ -22,6 +67,25 @@
2267
columns were dropped and warns about this. If stats intend to drop
2368
data columns they can declare them in the new field `dropped_aes`.
2469
(@clauswilke, #3250)
70+
71+
* `...` supports `rlang::list2` dynamic dots in all public functions.
72+
(@mone27, #4764)
73+
74+
* `theme()` now has a `strip.clip` argument, that can be set to `"off"` to
75+
prevent the clipping of strip text and background borders (@teunbrand, #4118)
76+
77+
* `geom_contour()` now accepts a function in the `breaks` argument
78+
(@eliocamp, #4652).
79+
80+
## Minor improvements and bug fixes
81+
82+
* Fix a bug in `position_jitter()` where infinity values were dropped (@javlon,
83+
#4790).
84+
85+
* `geom_linerange()` now respects the `na.rm` argument (#4927, @thomasp85)
86+
87+
* Improve the support for `guide_axis()` on `coord_trans()`
88+
(@yutannihilation, #3959)
2589

2690
* Added `stat_align()` to align data without common x-coordinates prior to
2791
stacking. This is now the default stat for `geom_area()` (@thomasp85, #4850)
@@ -30,26 +94,11 @@
3094
certain number of digits would cause the computations to fail (@thomasp85,
3195
#4874)
3296

33-
* `stage()` now properly refers to the values without scale transformations for
34-
the stage of `after_stat`. If your code requires the scaled version of the
35-
values for some reason, you have to apply the same transformation by yourself,
36-
e.g. `sqrt()` for `scale_{x,y}_sqrt()` (@yutannihilation and @teunbrand, #4155).
37-
38-
* A `linewidth` aesthetic has been introduced and supersedes the `size`
39-
aesthetic for scaling the width of lines in line based geoms. `size` will
40-
remain functioning but deprecated for these geoms and it is recommended to
41-
update all code to reflect the new aesthetic (@thomasp85, #3672)
42-
4397
* Secondary axis ticks are now positioned more precisely, removing small visual
4498
artefacts with alignment between grid and ticks (@thomasp85, #3576)
4599

46-
* Improve `stat_function` documentation regarding `xlim` argument. (@92amartins, #4474)
47-
48-
* `qplot()` is now formally deprecated (@yutannihilation, #3956).
49-
50-
* Use `rlang::hash()` instead of `digest::digest()`. This update may lead to
51-
changes in the automatic sorting of legends. In order to enforce a specific
52-
legend order use the `order` argument in the guide. (@thomasp85, #4458)
100+
* Improve `stat_function` documentation regarding `xlim` argument.
101+
(@92amartins, #4474)
53102

54103
* Fix various issues with how `labels`, `breaks`, `limits`, and `show.limits`
55104
interact in the different binning guides (@thomasp85, #4831)
@@ -62,11 +111,6 @@
62111
If used incorrectly, the warning will now report the duplicated aesthetic
63112
instead of `NA` (@teunbrand, #4707).
64113

65-
* `...` supports `rlang::list2` dynamic dots in all public functions. (@mone27, #4764)
66-
67-
* `theme()` now has a `strip.clip` argument, that can be set to `"off"` to
68-
prevent the clipping of strip text and background borders (@teunbrand, #4118)
69-
70114
* `aes()` now supports the `!!!` operator in its first two arguments
71115
(#2675). Thanks to @yutannihilation and @teunbrand for draft
72116
implementations.
@@ -81,9 +125,6 @@
81125

82126
* `presidential` dataset now includes Trump's presidency (@bkmgit, #4703).
83127

84-
* referring to `x` in backquoted expressions with `label_bquote()` is no longer
85-
possible.
86-
87128
* `position_stack()` now works fully with `geom_text()` (@thomasp85, #4367)
88129

89130
* `geom_tile()` now correctly recognises missing data in `xmin`, `xmax`, `ymin`,
@@ -106,8 +147,9 @@
106147
* Binning scales are now more resilient to calculated limits that ends up being
107148
`NaN` after transformations (@thomasp85, #4510)
108149

109-
* Strip padding in `facet_grid()` is now only in effect if `strip.placement = "outside"`
110-
_and_ an axis is present between the strip and the panel (@thomasp85, #4610)
150+
* Strip padding in `facet_grid()` is now only in effect if
151+
`strip.placement = "outside"` _and_ an axis is present between the strip and
152+
the panel (@thomasp85, #4610)
111153

112154
* Aesthetics of length 1 are now recycled to 0 if the length of the data is 0
113155
(@thomasp85, #4588)
@@ -134,27 +176,18 @@
134176
all `values` on the legend instead, use
135177
`scale_*_manual(values = vals, limits = names(vals))`. (@teunbrand, @banfai,
136178
#4511, #4534)
137-
138-
* `geom_contour()` now accepts a function in the `breaks` argument (@eliocamp, #4652).
139-
140-
* VISUAL CHANGE: `scale_*_viridis_b()` now uses the full range of the viridis scales (@gregleleu, #4737)
141179

142180
* Updated documentation for `geom_contour()` to correctly reflect argument
143-
precedence between `bins` and `binwidth`. (@eliocamp, #4651)
144-
145-
* The `ticks.linewidth` and `frame.linewidth` parameters of `guide_colourbar()`
146-
are now multiplied with `.pt` like elsewhere in ggplot2. It can cause visual
147-
changes when these arguments are not the defaults and these changes can be
148-
restored to their previous behaviour by adding `/ .pt` (@teunbrand #4314).
181+
precedence between `bins` and `binwidth`. (@eliocamp, #4651)
149182

150183
* Dots in `geom_dotplot()` are now correctly aligned to the baseline when
151184
`stackratio != 1` and `stackdir != "up"` (@mjskay, #4614)
152185

153186
* Key glyphs for `geom_boxplot()`, `geom_crossbar()`, `geom_pointrange()`, and
154187
`geom_linerange()` are now orientation-aware (@mjskay, #4732)
155188

156-
* Updated documentation for `geom_smooth()` to more clearly describe effects of the
157-
`fullrange` parameter (@thoolihan, #4399).
189+
* Updated documentation for `geom_smooth()` to more clearly describe effects of
190+
the `fullrange` parameter (@thoolihan, #4399).
158191

159192
# ggplot2 3.3.6
160193
This is a very small release only applying an internal change to comply with

R/aes-evaluation.r

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ is_calculated <- function(x, warn = FALSE) {
115115
what <- I(glue("The dot-dot notation (`{x}`)"))
116116
var <- gsub(match_calculated_aes, "\\1", as.character(x))
117117
with <- I(glue("`after_stat({var})`"))
118-
lifecycle::deprecate_warn("3.4.0", what, with, id = "ggplot-warn-aes-dot-dot")
118+
deprecate_warn0("3.4.0", what, with, id = "ggplot-warn-aes-dot-dot")
119119
}
120120
res
121121
} else if (is_quosure(x)) {
@@ -126,7 +126,7 @@ is_calculated <- function(x, warn = FALSE) {
126126
what <- I(glue("`{expr_deparse(x)}`"))
127127
x[[1]] <- quote(after_stat)
128128
with <- I(glue("`{expr_deparse(x)}`"))
129-
lifecycle::deprecate_warn("3.4.0", what, with, id = "ggplot-warn-aes-stat")
129+
deprecate_warn0("3.4.0", what, with, id = "ggplot-warn-aes-stat")
130130
}
131131
TRUE
132132
} else {

R/aes.r

+5-5
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ standardise_aes_symbols <- function(x) {
208208

209209
# Look up the scale that should be used for a given aesthetic
210210
aes_to_scale <- function(var) {
211-
var[var %in% c("x", "xmin", "xmax", "xend", "xintercept")] <- "x"
212-
var[var %in% c("y", "ymin", "ymax", "yend", "yintercept")] <- "y"
211+
var[var %in% ggplot_global$x_aes] <- "x"
212+
var[var %in% ggplot_global$y_aes] <- "y"
213213

214214
var
215215
}
@@ -265,7 +265,7 @@ is_position_aes <- function(vars) {
265265
#'
266266
#' @export
267267
aes_ <- function(x, y, ...) {
268-
lifecycle::deprecate_soft(
268+
deprecate_soft0(
269269
"3.0.0",
270270
"aes_()",
271271
details = "Please use tidy evaluation ideoms with `aes()`"
@@ -292,7 +292,7 @@ aes_ <- function(x, y, ...) {
292292
#' @rdname aes_
293293
#' @export
294294
aes_string <- function(x, y, ...) {
295-
lifecycle::deprecate_soft(
295+
deprecate_soft0(
296296
"3.0.0",
297297
"aes_string()",
298298
details = "Please use tidy evaluation ideoms with `aes()`"
@@ -346,7 +346,7 @@ aes_all <- function(vars) {
346346
#' @keywords internal
347347
#' @export
348348
aes_auto <- function(data = NULL, ...) {
349-
lifecycle::deprecate_warn("2.0.0", "aes_auto()")
349+
deprecate_warn0("2.0.0", "aes_auto()")
350350

351351
# detect names of data
352352
if (is.null(data)) {

R/annotation.r

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ annotate <- function(geom, x = NULL, y = NULL, xmin = NULL, xmax = NULL,
4242
ymin = NULL, ymax = NULL, xend = NULL, yend = NULL, ...,
4343
na.rm = FALSE) {
4444

45-
if (geom %in% c("abline", "hline", "vline")) {
45+
if (is.character(geom) && geom %in% c("abline", "hline", "vline")) {
4646
cli::cli_warn(c(
4747
"{.arg geom} must not be {.val {geom}}.",
4848
"i" = "Please use {.fn {paste0('geom_', geom)}} directly instead."

R/compat-plyr.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ count <- function(df, vars = NULL, wt_var = NULL) {
159159
# Create a shared unique id across two data frames such that common variable
160160
# combinations in the two data frames gets the same id
161161
join_keys <- function(x, y, by) {
162-
joint <- vec_rbind(x[by], y[by])
162+
joint <- vec_rbind0(x[by], y[by])
163163
keys <- id(joint, drop = TRUE)
164164
n_x <- nrow(x)
165165
n_y <- nrow(y)
@@ -298,7 +298,7 @@ dapply <- function(df, by, fun, ..., drop = TRUE) {
298298
cur_data <- df_rows(df, group_rows[[i]])
299299
apply_fun(cur_data)
300300
})
301-
vec_rbind(!!!result)
301+
vec_rbind0(!!!result)
302302
}
303303

304304
single_value <- function(x, ...) {

R/coord-.r

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Coord <- ggproto("Coord",
6262
labels = function(self, labels, panel_params) {
6363
# If panel params contains guides information, use it.
6464
# Otherwise use the labels as is, for backward-compatibility
65-
if (is.null(panel_params$guide)) {
65+
if (is.null(panel_params$guides)) {
6666
return(labels)
6767
}
6868

0 commit comments

Comments
 (0)