Skip to content

Commit 5f0527d

Browse files
authored
Merge pull request #32 from tidyverse/master
Sync Fork from Upstream Repo
2 parents 1873469 + bf8786d commit 5f0527d

File tree

14 files changed

+97
-40
lines changed

14 files changed

+97
-40
lines changed

.github/workflows/pkgdown.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ jobs:
3636
- name: Install dependencies
3737
run: |
3838
remotes::install_deps(dependencies = TRUE, type = "binary")
39-
remotes::install_github("tidyverse/tidytemplate")
40-
remotes::install_dev("pkgdown")
39+
remotes::install_github("tidyverse/tidytemplate", type = "binary")
40+
remotes::install_dev("pkgdown", type = "binary")
4141
shell: Rscript {0}
4242

4343
- name: Install package

NEWS.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# ggplot2 (development version)
22

3+
* `coord_sf()` now has an argument `default_crs` that specifies the coordinate
4+
reference system (CRS) for non-sf layers and scale/coord limits. This argument
5+
defaults to the World Geodetic System 1984 (WGS84), which means x and y positions
6+
are interpreted as longitude and latitude. This is a potentially breaking change
7+
for users who use projected coordinates in non-sf layers or in limits. Setting
8+
`default_crs = NULL` recovers the old behavior. Further, authors of extension
9+
packages implementing `stat_sf()`-like functionality are encouraged to look at the
10+
source code of `stat_sf()`'s `compute_group()` function to see how to provide
11+
scale-limit hints to `coord_sf()` (@clauswilke, #3659).
12+
313
* `ggsave()` now sets the default background to match the fill value of the
414
`plot.background` theme element (@karawoo, #4057)
515

@@ -22,12 +32,21 @@
2232

2333
* `stat_bin()`'s computed variable `width` is now documented (#3522).
2434

35+
* Fixed a bug in strip assembly when theme has `strip.text = element_blank()`
36+
and plots are faceted with multi-layered strips (@teunbrand, #4384).
37+
2538
* ggplot2 now requires R >= 3.3 (#4247).
2639

2740
* ggplot2 now uses `rlang::check_installed()` to check if a suggested package is
2841
installed, which will offer to install the package before continuing (#4375,
2942
@malcolmbarrett)
3043

44+
* Improved error with hint when piping a `ggplot` object into a facet function
45+
(#4379, @mitchelloharawild).
46+
47+
* Fix a bug that `after_stat()` and `after_scale()` cannot refer to aesthetics
48+
if it's specified in the plot-global mapping (@yutannihilation, #4260).
49+
3150
# ggplot2 3.3.3
3251
This is a small patch release mainly intended to address changes in R and CRAN.
3352
It further changes the licensing model of ggplot2 to an MIT license.
@@ -38,6 +57,9 @@ It further changes the licensing model of ggplot2 to an MIT license.
3857

3958
* Update tests to work with the new `all.equal()` defaults in R >4.0.3
4059

60+
* Fixed a bug that `guide_bins()` mistakenly ignore `override.aes` argument
61+
(@yutannihilation, #4085).
62+
4163
# ggplot2 3.3.2
4264
This is a small release focusing on fixing regressions introduced in 3.3.1.
4365

@@ -46,16 +68,6 @@ This is a small release focusing on fixing regressions introduced in 3.3.1.
4668

4769
* `annotation_raster()` adds support for native rasters. For large rasters,
4870
native rasters render significantly faster than arrays (@kent37, #3388)
49-
50-
* `coord_sf()` now has an argument `default_crs` that specifies the coordinate
51-
reference system (CRS) for non-sf layers and scale/coord limits. This argument
52-
defaults to the World Geodetic System 1984 (WGS84), which means x and y positions
53-
are interpreted as longitude and latitude. This is a potentially breaking change
54-
for users who use projected coordinates in non-sf layers or in limits. Setting
55-
`default_crs = NULL` recovers the old behavior. Further, authors of extension
56-
packages implementing `stat_sf()`-like functionality are encouraged to look at the
57-
source code of `stat_sf()`'s `compute_group()` function to see how to provide
58-
scale-limit hints to `coord_sf()` (@clauswilke, #3659).
5971

6072
* Facet strips now have dedicated position-dependent theme elements
6173
(`strip.text.x.top`, `strip.text.x.bottom`, `strip.text.y.left`,

R/facet-.r

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ df.grid <- function(a, b) {
276276
# facetting variables.
277277

278278
as_facets_list <- function(x) {
279-
if (inherits(x, "uneval")) {
280-
abort("Please use `vars()` to supply facet variables")
281-
}
279+
x <- validate_facets(x)
282280
if (is_quosures(x)) {
283281
x <- quos_auto_name(x)
284282
return(list(x))
@@ -315,11 +313,24 @@ as_facets_list <- function(x) {
315313
x
316314
}
317315

316+
validate_facets <- function(x) {
317+
if (inherits(x, "uneval")) {
318+
abort("Please use `vars()` to supply facet variables")
319+
}
320+
if (inherits(x, "ggplot")) {
321+
abort(
322+
"Please use `vars()` to supply facet variables\nDid you use %>% instead of +?"
323+
)
324+
}
325+
x
326+
}
327+
328+
318329
# Flatten a list of quosures objects to a quosures object, and compact it
319330
compact_facets <- function(x) {
320331
x <- flatten_if(x, is_list)
321-
null <- vapply(x, quo_is_null, logical(1))
322-
new_quosures(x[!null])
332+
null_or_missing <- vapply(x, function(x) quo_is_null(x) || quo_is_missing(x), logical(1))
333+
new_quosures(x[!null_or_missing])
323334
}
324335

325336
# Compatibility with plyr::as.quoted()

R/facet-grid-.r

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,14 @@ grid_as_facets_list <- function(rows, cols) {
157157
is_rows_vars <- is.null(rows) || is_quosures(rows)
158158
if (!is_rows_vars) {
159159
if (!is.null(cols)) {
160-
abort("`rows` must be `NULL` or a `vars()` list if `cols` is a `vars()` list")
160+
msg <- "`rows` must be `NULL` or a `vars()` list if `cols` is a `vars()` list"
161+
if(inherits(rows, "ggplot")) {
162+
msg <- paste0(
163+
msg, "\n",
164+
"Did you use %>% instead of +?"
165+
)
166+
}
167+
abort(msg)
161168
}
162169
# For backward-compatibility
163170
facets_list <- as_facets_list(rows)

R/facet-wrap.r

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ facet_wrap <- function(facets, nrow = NULL, ncol = NULL, scales = "fixed",
8686
x = any(scales %in% c("free_x", "free")),
8787
y = any(scales %in% c("free_y", "free"))
8888
)
89+
90+
# Check for deprecated labellers
91+
labeller <- check_labeller(labeller)
92+
93+
# Flatten all facets dimensions into a single one
94+
facets <- wrap_as_facets_list(facets)
95+
8996
if (!is.null(switch)) {
9097
.Deprecated("strip.position", old = "switch")
9198
strip.position <- if (switch == "x") "bottom" else "left"
@@ -102,12 +109,6 @@ facet_wrap <- function(facets, nrow = NULL, ncol = NULL, scales = "fixed",
102109
ncol <- sanitise_dim(ncol)
103110
}
104111

105-
# Check for deprecated labellers
106-
labeller <- check_labeller(labeller)
107-
108-
# Flatten all facets dimensions into a single one
109-
facets <- wrap_as_facets_list(facets)
110-
111112
ggproto(NULL, FacetWrap,
112113
shrink = shrink,
113114
params = list(

R/guide-bins.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ guide_bins <- function(
116116

117117
# general
118118
direction = direction,
119+
override.aes = rename_aes(override.aes),
119120
default.unit = default.unit,
120121
reverse = reverse,
121122
order = order,

R/labeller.r

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,11 @@ build_strip <- function(label_df, labeller, theme, horizontal) {
553553
#'
554554
#' @noRd
555555
assemble_strips <- function(grobs, theme, horizontal = TRUE, clip) {
556-
if (length(grobs) == 0 || is.zero(grobs[[1]])) return(grobs)
556+
if (length(grobs) == 0 || is.zero(grobs[[1]])) {
557+
# Subsets matrix of zeroGrobs to correct length (#4050)
558+
grobs <- grobs[seq_len(NROW(grobs))]
559+
return(grobs)
560+
}
557561

558562
# Add margins to non-titleGrobs so they behave eqivalently
559563
grobs[] <- lapply(grobs, function(g) {

R/layer.r

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,18 @@ Layer <- ggproto("Layer", NULL,
203203
# hook to allow a layer access to the final layer data
204204
# in input form and to global plot info
205205
setup_layer = function(self, data, plot) {
206+
# For annotation geoms, it is useful to be able to ignore the default aes
207+
if (isTRUE(self$inherit.aes)) {
208+
self$mapping <- defaults(self$mapping, plot$mapping)
209+
# defaults() strips class, but it needs to be preserved for now
210+
class(self$mapping) <- "uneval"
211+
}
212+
206213
data
207214
},
208215

209216
compute_aesthetics = function(self, data, plot) {
210-
# For annotation geoms, it is useful to be able to ignore the default aes
211-
if (self$inherit.aes) {
212-
aesthetics <- defaults(self$mapping, plot$mapping)
213-
} else {
214-
aesthetics <- self$mapping
215-
}
217+
aesthetics <- self$mapping
216218

217219
# Drop aesthetics that are set or calculated
218220
set <- names(aesthetics) %in% names(self$aes_params)
@@ -289,9 +291,6 @@ Layer <- ggproto("Layer", NULL,
289291

290292
# Assemble aesthetics from layer, plot and stat mappings
291293
aesthetics <- self$mapping
292-
if (self$inherit.aes) {
293-
aesthetics <- defaults(aesthetics, plot$mapping)
294-
}
295294
aesthetics <- defaults(aesthetics, self$stat$default_aes)
296295
aesthetics <- compact(aesthetics)
297296

R/save.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#' @param filename File name to create on disk.
2626
#' @param plot Plot to save, defaults to last plot displayed.
2727
#' @param device Device to use. Can either be a device function
28-
#' (e.g. [png()]), or one of "eps", "ps", "tex" (pictex),
28+
#' (e.g. [png]), or one of "eps", "ps", "tex" (pictex),
2929
#' "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf" (windows only).
3030
#' @param path Path of the directory to save plot to: `path` and `filename`
3131
#' are combined to create the fully qualified file name. Defaults to the

R/stat-bindot.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ StatBindot <- ggproto("StatBindot", Stat,
99

1010
setup_params = function(data, params) {
1111
if (is.null(params$binwidth)) {
12-
message("`stat_bindot()` using `bins = 30`. Pick better value with `binwidth`.")
12+
message("Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.")
1313
}
1414
params
1515
},

0 commit comments

Comments
 (0)