Skip to content

Commit e9b9946

Browse files
authored
Merge RC back into master
2 parents 84212b0 + 3cd0280 commit e9b9946

37 files changed

+7330
-9465
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ visual_test
2525
^appveyor\.yml$
2626
^\.github$
2727
^vignettes/profilings
28+
^vignettes/profiling.Rmd$
2829
^cran-comments\.md$
2930
^LICENSE\.md$

NEWS.md

Lines changed: 110 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# ggplot2 (development version)
2-
31
* `annotation_raster()` adds support for native rasters. For large rasters,
42
native rasters render significantly faster than arrays (@kent37, #3388)
53

@@ -8,11 +6,41 @@
86

97
* Added an `outside` option to `annotation_logticks()` that places tick marks
108
outside of the plot bounds. (#3783, @kbodwin)
11-
9+
1210
# ggplot2 3.3.0
1311

14-
* Fix a bug in `geom_raster()` that squeezed the image when it went outside
15-
scale limits (#3539, @thomasp85)
12+
This is a minor release but does contain a range of substantial new features,
13+
along with the standard bug fixes. The release contains a few visual breaking
14+
changes, along with breaking changes for extension developers due to a shift in
15+
internal representation of the position scales and their axes. No user breaking
16+
changes are included.
17+
18+
This release also adds Dewey Dunnington (@paleolimbot) to the core team.
19+
20+
## Breaking changes
21+
There are no user-facing breaking changes, but a change in some internal
22+
representations that extension developers may have relied on, along with a few
23+
breaking visual changes which may cause visual tests in downstream packages to
24+
fail.
25+
26+
* The `panel_params` field in the `Layout` now contains a list of list of
27+
`ViewScale` objects, describing the trained coordinate system scales, instead
28+
of the list object used before. Any extensions that use this field will likely
29+
break, as will unit tests that checks aspects of this.
30+
31+
* `element_text()` now issues a warning when vectorized arguments are provided,
32+
as in `colour = c("red", "green", "blue")`. Such use is discouraged and not
33+
officially supported (@clauswilke, #3492).
34+
35+
* Changed `theme_grey()` setting for legend key so that it creates no border
36+
(`NA`) rather than drawing a white one. (@annennenne, #3180)
37+
38+
* `geom_ribbon()` now draws separate lines for the upper and lower intervals if
39+
`colour` is mapped. Similarly, `geom_area()` and `geom_density()` now draw
40+
the upper lines only in the same case by default. If you want old-style full
41+
stroking, use `outline.type = "full"` (@yutannihilation, #3503 / @thomasp85, #3708).
42+
43+
## New features
1644

1745
* The evaluation time of aesthetics can now be controlled to a finer degree.
1846
`after_stat()` supersedes the use of `stat()` and `..var..`-notation, and is
@@ -21,75 +49,57 @@
2149
map a data variable to a stat aesthetic, and remap the same aesthetic to
2250
something else after statistical transformation (@thomasp85, #3534)
2351

24-
* ggplot2 no longer depends on reshape2, which means that it no longer
25-
(recursively) needs plyr, stringr, or stringi packages.
52+
* All `coord_*()` functions with `xlim` and `ylim` arguments now accept
53+
vectors with `NA` as a placeholder for the minimum or maximum value
54+
(e.g., `ylim = c(0, NA)` would zoom the y-axis from 0 to the
55+
maximum value observed in the data). This mimics the behaviour
56+
of the `limits` argument in continuous scale functions
57+
(@paleolimbot, #2907).
2658

27-
* `geom_sf()` now determines the legend type automatically (@microly, #3646).
59+
* Allowed reversing of discrete scales by re-writing `get_limits()`
60+
(@AnneLyng, #3115)
2861

29-
* `scale_x_continuous()` and `scale_y_continuous()` gains an `n.breaks` argument
30-
guiding the number of automatic generated breaks (@thomasp85, #3102)
62+
* All geoms and stats that had a direction (i.e. where the x and y axes had
63+
different interpretation), can now freely choose their direction, instead of
64+
relying on `coord_flip()`. The direction is deduced from the aesthetic
65+
mapping, but can also be specified directly with the new `orientation`
66+
argument (@thomasp85, #3506).
67+
68+
* Position guides can now be customized using the new `guide_axis()`, which can
69+
be passed to position `scale_*()` functions or via `guides()`. The new axis
70+
guide (`guide_axis()`) comes with arguments `check.overlap` (automatic removal
71+
of overlapping labels), `angle` (easy rotation of axis labels), and
72+
`n.dodge` (dodge labels into multiple rows/columns) (@paleolimbot, #3322).
3173

32-
* `geom_sf()` now removes rows that can't be plotted due to `NA` aesthetics
33-
(#3546, @thomasp85)
34-
3574
* A new scale type has been added, that allows binning of aesthetics at the
3675
scale level. It has versions for both position and non-position aesthetics and
37-
comes with two new guides (`guide_bins` and `guide_coloursteps`) (@thomasp85, #3096)
76+
comes with two new guides (`guide_bins` and `guide_coloursteps`)
77+
(@thomasp85, #3096)
3878

39-
* Position guides can now be customized using the new `guide_axis()`,
40-
which can be passed to position `scale_*()` functions or via
41-
`guides()`. The new axis guide (`guide_axis()`) comes with
42-
arguments `check.overlap` (automatic removal of overlapping
43-
labels), `angle` (easy rotation of axis labels), and
44-
`n.dodge` (dodge labels into multiple rows/columns) (@paleolimbot, #3322).
45-
46-
* `Geom` now gains a `setup_params()` method in line with the other ggproto
47-
classes (@thomasp85, #3509)
48-
49-
* The newly added function `register_theme_elements()` now allows developers
50-
of extension packages to define their own new theme elements and place them
51-
into the ggplot2 element tree (@clauswilke, #2540).
52-
53-
* `element_text()` now issues a warning when vectorized arguments are provided, as in
54-
`colour = c("red", "green", "blue")`. Such use is discouraged and not officially supported
55-
(@clauswilke, #3492).
56-
57-
* Addition of partial themes to plots has been made more predictable;
58-
stepwise addition of individual partial themes is now equivalent to
59-
addition of multple theme elements at once (@clauswilke, #3039).
60-
61-
* stacking text when calculating the labels and the y axis with
62-
`stat_summary()` now works (@ikosmidis, #2709)
63-
64-
* Allowed reversing of discrete scales by re-writing `get_limits()` (@AnneLyng, #3115)
79+
* `scale_x_continuous()` and `scale_y_continuous()` gains an `n.breaks` argument
80+
guiding the number of automatic generated breaks (@thomasp85, #3102)
6581

6682
* Added `stat_contour_filled()` and `geom_contour_filled()`, which compute
67-
and draw filled contours of gridded data (@paleolimbot, #3044).
68-
69-
* `geom_contour()` and `stat_contour()` now use the isoband package
83+
and draw filled contours of gridded data (@paleolimbot, #3044).
84+
`geom_contour()` and `stat_contour()` now use the isoband package
7085
to compute contour lines. The `complete` parameter (which was undocumented
7186
and has been unused for at least four years) was removed (@paleolimbot, #3044).
72-
73-
* `stat_smooth()` uses `REML` by default, if `method = "gam"` and
74-
`gam`'s method is not specified (@ikosmidis, #2630).
75-
76-
* Changed `theme_grey()` setting for legend key so that it creates no
77-
border (`NA`) rather than drawing a white one. (@annennenne, #3180)
7887

7988
* Themes have gained two new parameters, `plot.title.position` and
8089
`plot.caption.position`, that can be used to customize how plot
8190
title/subtitle and plot caption are positioned relative to the overall plot
8291
(@clauswilke, #3252).
8392

84-
* Added function `ggplot_add.by()` for lists created with `by()` (#2734, @Maschette)
85-
86-
* `gg_dep()` was deprecated (@perezp44, #3382).
93+
## Extensions
94+
95+
* `Geom` now gains a `setup_params()` method in line with the other ggproto
96+
classes (@thomasp85, #3509)
8797

88-
* Added weight aesthetic option to `stat_density()` and made scaling of
89-
weights the default (@annennenne, #2902)
98+
* The newly added function `register_theme_elements()` now allows developers
99+
of extension packages to define their own new theme elements and place them
100+
into the ggplot2 element tree (@clauswilke, #2540).
90101

91-
* `expand_scale()` was deprecated in favour of `expansion()` for setting
92-
the `expand` argument of `x` and `y` scales (@paleolimbot).
102+
## Minor improvements and bug fixes
93103

94104
* `coord_trans()` now draws second axes and accepts `xlim`, `ylim`,
95105
and `expand` arguments to bring it up to feature parity with
@@ -104,43 +114,71 @@
104114
in `coord_trans()` was also updated such that it behaves identically
105115
to that in `coord_cartesian()` (@paleolimbot, #3338).
106116

107-
* All `coord_*()` functions with `xlim` and `ylim` arguments now accept
108-
vectors with `NA` as a placeholder for the minimum or maximum value
109-
(e.g., `ylim = c(0, NA)` would zoom the y-axis from 0 to the
110-
maximum value observed in the data). This mimics the behaviour
111-
of the `limits` argument in continuous scale functions
112-
(@paleolimbot, #2907).
117+
* `expand_scale()` was deprecated in favour of `expansion()` for setting
118+
the `expand` argument of `x` and `y` scales (@paleolimbot).
113119

114120
* `geom_abline()`, `geom_hline()`, and `geom_vline()` now issue
115121
more informative warnings when supplied with set aesthetics
116122
(i.e., `slope`, `intercept`, `yintercept`, and/or `xintercept`)
117123
and mapped aesthetics (i.e., `data` and/or `mapping`).
124+
125+
* Fix a bug in `geom_raster()` that squeezed the image when it went outside
126+
scale limits (#3539, @thomasp85)
127+
128+
* `geom_sf()` now determines the legend type automatically (@microly, #3646).
118129

119-
* `stat_density2d()` can now take an `adjust` parameter to scale the default bandwidth. (#2860, @haleyjeppson)
130+
* `geom_sf()` now removes rows that can't be plotted due to `NA` aesthetics
131+
(#3546, @thomasp85)
120132

121-
* Fix a bug when `show.legend` is a named logical vector (#3461, @yutannihilation).
133+
* `geom_sf()` now applies alpha to linestring geometries
134+
(#3589, @yutannihilation).
135+
136+
* `gg_dep()` was deprecated (@perezp44, #3382).
122137

123-
* Increase the default `nbin` of `guide_colourbar()` to place the ticks more precisely (#3508, @yutannihilation).
138+
* Added function `ggplot_add.by()` for lists created with `by()`, allowing such
139+
lists to be added to ggplot objects (#2734, @Maschette)
140+
141+
* ggplot2 no longer depends on reshape2, which means that it no longer
142+
(recursively) needs plyr, stringr, or stringi packages.
124143

125-
* `geom_sf()` now applies alpha to linestring geometries (#3589, @yutannihilation).
144+
* Increase the default `nbin` of `guide_colourbar()` to place the ticks more
145+
precisely (#3508, @yutannihilation).
126146

127147
* `manual_scale()` now matches `values` with the order of `breaks` whenever
128148
`values` is an unnamed vector. Previously, unnamed `values` would match with
129149
the limits of the scale and ignore the order of any `breaks` provided. Note
130150
that this may change the appearance of plots that previously relied on the
131151
unordered behaviour (#2429, @idno0001).
152+
153+
* `scale_manual_*(limits = ...)` now actually limits the scale (#3262,
154+
@yutannihilation).
155+
156+
* Fix a bug when `show.legend` is a named logical vector
157+
(#3461, @yutannihilation).
158+
159+
* Added weight aesthetic option to `stat_density()` and made scaling of
160+
weights the default (@annennenne, #2902)
161+
162+
* `stat_density2d()` can now take an `adjust` parameter to scale the default
163+
bandwidth. (#2860, @haleyjeppson)
164+
165+
* `stat_smooth()` uses `REML` by default, if `method = "gam"` and
166+
`gam`'s method is not specified (@ikosmidis, #2630).
167+
168+
* stacking text when calculating the labels and the y axis with
169+
`stat_summary()` now works (@ikosmidis, #2709)
132170

133171
* `stat_summary()` and related functions now support rlang-style lambda functions
134172
(#3568, @dkahle).
135173

136-
* `geom_ribbon()` now draws separate lines for the upper and lower intervals if
137-
`colour` is mapped by default. Similarly, `geom_area()` now draws lines for
138-
the upper in the same case by default. If you want old-style full stroking, use
139-
`outline.type = "legacy"` (#3503, @yutannihilation).
174+
* The data mask pronoun, `.data`, is now stripped from default labels.
140175

141-
* `scale_manual_*(limits = ...)` now actually limits the scale (#3262,
142-
@yutannihilation).
176+
* Addition of partial themes to plots has been made more predictable;
177+
stepwise addition of individual partial themes is now equivalent to
178+
addition of multple theme elements at once (@clauswilke, #3039).
143179

180+
* Facets now don't fail even when some variable in the spec are not available
181+
in all layers (@yutannihilation, #2963).
144182

145183
# ggplot2 3.2.1
146184

R/aes-evaluation.r

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ is_staged <- function(x) {
132132
}
133133

134134
# Strip dots from expressions
135-
strip_dots <- function(expr) {
135+
strip_dots <- function(expr, env, strip_pronoun = FALSE) {
136136
if (is.atomic(expr)) {
137137
expr
138138
} else if (is.name(expr)) {
@@ -144,23 +144,30 @@ strip_dots <- function(expr) {
144144
}
145145
} else if (is_quosure(expr)) {
146146
# strip dots from quosure and reconstruct the quosure
147-
expr <- new_quosure(
148-
strip_dots(quo_get_expr(expr)),
147+
new_quosure(
148+
strip_dots(quo_get_expr(expr), env = quo_get_env(expr), strip_pronoun = strip_pronoun),
149149
quo_get_env(expr)
150150
)
151151
} else if (is.call(expr)) {
152-
if (identical(expr[[1]], quote(stat))) {
153-
strip_dots(expr[[2]])
152+
if (strip_pronoun && is_call(expr, "$") && is_symbol(expr[[2]], ".data")) {
153+
strip_dots(expr[[3]], env, strip_pronoun = strip_pronoun)
154+
} else if (strip_pronoun && is_call(expr, "[[") && is_symbol(expr[[2]], ".data")) {
155+
tryCatch(
156+
sym(eval(expr[[3]], env)),
157+
error = function(e) expr[[3]]
158+
)
159+
} else if (is_call(expr, "stat")) {
160+
strip_dots(expr[[2]], env, strip_pronoun = strip_pronoun)
154161
} else {
155-
expr[-1] <- lapply(expr[-1], strip_dots)
162+
expr[-1] <- lapply(expr[-1], strip_dots, env = env, strip_pronoun = strip_pronoun)
156163
expr
157164
}
158165
} else if (is.pairlist(expr)) {
159166
# In the unlikely event of an anonymous function
160-
as.pairlist(lapply(expr, strip_dots))
167+
as.pairlist(lapply(expr, strip_dots, env = env, strip_pronoun = strip_pronoun))
161168
} else if (is.list(expr)) {
162169
# For list of aesthetics
163-
lapply(expr, strip_dots)
170+
lapply(expr, strip_dots, env = env, strip_pronoun = strip_pronoun)
164171
} else {
165172
abort(glue("Unknown input: {class(expr)[1]}"))
166173
}
@@ -187,7 +194,7 @@ make_labels <- function(mapping) {
187194
return(aesthetic)
188195
}
189196
mapping <- strip_stage(mapping)
190-
mapping <- strip_dots(mapping)
197+
mapping <- strip_dots(mapping, strip_pronoun = TRUE)
191198
if (is_quosure(mapping) && quo_is_symbol(mapping)) {
192199
name <- as_string(quo_get_expr(mapping))
193200
} else {

R/compat-plyr.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,22 @@ rbind_dfs <- function(dfs) {
273273
allocated <- rep(FALSE, length(columns))
274274
names(allocated) <- columns
275275
col_levels <- list()
276+
ord_levels <- list()
276277
for (df in dfs) {
277278
new_columns <- intersect(names(df), columns[!allocated])
278279
for (col in new_columns) {
279280
if (is.factor(df[[col]])) {
281+
all_ordered <- all(vapply(dfs, function(df) {
282+
val <- .subset2(df, col)
283+
is.null(val) || is.ordered(val)
284+
}, logical(1)))
280285
all_factors <- all(vapply(dfs, function(df) {
281286
val <- .subset2(df, col)
282287
is.null(val) || is.factor(val)
283288
}, logical(1)))
284-
if (all_factors) {
289+
if (all_ordered) {
290+
ord_levels[[col]] <- unique(unlist(lapply(dfs, function(df) levels(.subset2(df, col)))))
291+
} else if (all_factors) {
285292
col_levels[[col]] <- unique(unlist(lapply(dfs, function(df) levels(.subset2(df, col)))))
286293
}
287294
out[[col]] <- rep(NA_character_, total)
@@ -318,6 +325,9 @@ rbind_dfs <- function(dfs) {
318325
}
319326
}
320327
}
328+
for (col in names(ord_levels)) {
329+
out[[col]] <- ordered(out[[col]], levels = ord_levels[[col]])
330+
}
321331
for (col in names(col_levels)) {
322332
out[[col]] <- factor(out[[col]], levels = col_levels[[col]])
323333
}

0 commit comments

Comments
 (0)