Skip to content

Commit 232f3fc

Browse files
committed
Merge branch 'main' into lgaborini-layer-names
2 parents 78a1608 + 8491112 commit 232f3fc

24 files changed

+87
-43
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: ggplot2
22
Title: Create Elegant Data Visualisations Using the Grammar of Graphics
3-
Version: 4.0.0.9000
3+
Version: 4.0.1.9000
44
Authors@R: c(
55
person("Hadley", "Wickham", , "[email protected]", role = "aut",
66
comment = c(ORCID = "0000-0003-4757-117X")),

NEWS.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,47 @@
11
# ggplot2 (development version)
22

3+
# ggplot2 4.0.1
4+
5+
This is a smaller patch release focussed on fixing regressions from 4.0.0 and
6+
polishing the recent features.
7+
8+
## Bug fixes
9+
310
* Fixed regression where `geom_area()` didn't draw panels with single groups
411
when `stat = "align"` (@teunbrand, #6680)
512
* Fixed regression where `position_stack(vjust)` was ignored when there are
613
only single groups (#6692)
714
* Fixed bug where `NA` handling in `geom_path()` was ignoring panels (@teunbrand, #6533)
8-
* Logical values for the linetype aesthetic will be interpreted numerically,
9-
so that `linetype = FALSE` becomes 0/'blank' and `linetype = TRUE` becomes
10-
1/'solid' (@teunbrand, #6641)
11-
* Out-of-bounds datapoints used as padding by `stat_align()` now get removed
12-
silently rather than verbosely (@teunbrand, #6667)
1315
* Fixed bug where `stat_bin(boundary)` was ignored (#6682).
1416
* `geom_text()` and `geom_label()` accept expressions as the `label` aesthetic
1517
(@teunbrand, #6638)
1618
* Fixed regression where `draw_key_rect()` stopped using `fill` colours
1719
(@mitchelloharawild, #6609).
1820
* Fixed regression where `scale_{x,y}_*()` threw an error when an expression
1921
object is set to `labels` argument (@yutannihilation, #6617).
20-
* Improved palette fallback mechanism in scales (@teunbrand, #6669).
21-
* Allow `stat` in `geom_hline`, `geom_vline`, and `geom_abline`. (@sierrajohnson, #6559)
22-
* `stat_boxplot()` treats `width` as an optional aesthetic (@Yunuuuu, #6575)
2322
* Fixed regression where the first (unnamed) argument to colour/fill scales was
2423
not passed as the `name` argument (@teunbrand, #6623)
2524
* Fixed issue where vectorised `arrow()`s caused errors in drawing the
2625
legend glyphs (@teunbrand, #6594)
2726
* Fixed regression where `NULL`-aesthetics contributed to plot labels too
2827
insistently. Now they contribute only as fallback labels (@teunbrand, #6616)
28+
* Fixed regression where empty arguments to colour/fill scale caused errors
29+
(@jmbarbone, #6710)
30+
* Fixed axis misplacement in `coor_radial()` when labels are blank (@teunbrand, #6574)
31+
32+
## Improvements
33+
34+
* Improved palette fallback mechanism in scales (@teunbrand, #6669).
35+
* Allow `stat` in `geom_hline`, `geom_vline`, and `geom_abline`. (@sierrajohnson, #6559)
36+
* `stat_boxplot()` treats `width` as an optional aesthetic (@Yunuuuu, #6575)
2937
* The `theme(panel.widths, panel.heights)` setting attempts to preserve the
3038
plot's aspect ratio when only one of the two settings is given, and the plot
3139
has a single panel (@teunbrand, #6701).
32-
* Fixed axis misplacement in `coor_radial()` when labels are blank (@teunbrand, #6574)
40+
* Logical values for the linetype aesthetic will be interpreted numerically,
41+
so that `linetype = FALSE` becomes 0/'blank' and `linetype = TRUE` becomes
42+
1/'solid' (@teunbrand, #6641)
43+
* Out-of-bounds datapoints used as padding by `stat_align()` now get removed
44+
silently rather than verbosely (@teunbrand, #6667)
3345

3446
# ggplot2 4.0.0
3547

R/labels.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,13 @@ make_labels <- function(mapping) {
175175
#' See [get_alt_text] for examples. `alt` can also be a function that
176176
#' takes the plot as input and returns text as output. `alt` also accepts
177177
#' rlang [lambda][rlang::as_function()] function notation.
178-
#' @param ... A list of new name-value pairs. The name should be an aesthetic.
178+
#' @param ...
179+
#' New name-value pairs. The name should be an aesthetic. The values can be
180+
#' one of the following:
181+
#' * A string or expression to set a label verbatim.
182+
#' * A function to use as formatter for the default label.
183+
#' * `NULL` to remove a label.
184+
#' * A [`waiver()`] to use the default label.
179185
#' @export
180186
#'
181187
#' @seealso

R/layer.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,9 +972,8 @@ normalise_label <- function(label) {
972972
return(NULL)
973973
}
974974
if (obj_is_list(label)) {
975-
# Ensure that each element in the list has length 1
975+
# Ensure no elements are empty
976976
label[lengths(label) == 0] <- ""
977-
label <- lapply(label, `[`, 1)
978977
}
979978
if (is.expression(label)) {
980979
# Classed expressions, when converted to lists, retain their class.

R/position-.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ Position <- ggproto(
102102
#' A data frame with completed layer data
103103
use_defaults = function(self, data, params = list()) {
104104

105+
if (empty(data)) {
106+
return(data)
107+
}
108+
105109
aes <- self$aesthetics()
106110
defaults <- self$default_aes
107111

@@ -113,6 +117,13 @@ Position <- ggproto(
113117
return(data)
114118
}
115119

120+
empty_aes <- names(params)[lengths(params) == 0]
121+
if (length(empty_aes) > 0) {
122+
# The Geom$use_defaults method will already warn about this, we just need
123+
# to ignore this here.
124+
params <- params[setdiff(names(params), empty_aes)]
125+
}
126+
116127
new <- compact(lapply(defaults, eval_tidy, data = data))
117128
new[names(params)] <- params
118129
check_aesthetics(new, nrow(data))

R/scale-colour.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ check_scale_type <- function(scale, name, aesthetic, scale_is_discrete = FALSE,
285285
scale_backward_compatibility <- function(..., scale, aesthetic, type) {
286286
aesthetic <- standardise_aes_names(aesthetic[1])
287287

288-
args <- list2(...)
288+
# input ... may have trailing args, which then get stuck in the middle #6710
289+
args <- dots_list(..., .ignore_empty = "all")
289290
args$call <- args$call %||% caller_call() %||% current_call()
290291

291292
if (type == "binned") {

R/stat-align.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ StatAlign <- ggproto(
7777

7878
finish_layer = function(data, params) {
7979
# Silently remove out-of-bounds padding vertices
80-
var <- flipped_names(params$flipped_aes)$x
80+
var <- flipped_names(params$flipped_aes %||% FALSE)$x
8181
remove <- is.na(data[[var]]) & (data$align_padding %||% FALSE)
8282
vec_slice(data, !remove)
8383
}

R/utilities-help.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ rd_orientation <- function() {
9090
c(
9191
"@section Orientation: ",
9292
paste(
93-
'This geom treats each axis differently and, thus, can thus have two orientations.',
93+
'This geom treats each axis differently and, thus, can have two orientations.',
9494
'Often the orientation is easy to deduce from a combination of the given',
9595
'mappings and the types of positional scales in use. Thus, ggplot2 will by',
9696
'default try to guess which orientation the layer should have. Under rare',

README.Rmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pak::pak("tidyverse/ggplot2")
4242

4343
## Cheatsheet
4444

45-
<a href="https://github.com/rstudio/cheatsheets/blob/master/data-visualization.pdf"><img src="https://raw.githubusercontent.com/rstudio/cheatsheets/master/pngs/thumbnails/data-visualization-cheatsheet-thumbs.png" width="630" height="252" alt="ggplot2 cheatsheet" /></a>
45+
<a href="https://github.com/rstudio/cheatsheets/blob/main/data-visualization.pdf"><img src="https://raw.githubusercontent.com/rstudio/cheatsheets/main/pngs/thumbnails/data-visualization-cheatsheet-thumbs.png" width="630" height="252" alt="ggplot2 cheatsheet" /></a>
4646

4747
## Usage
4848

@@ -76,7 +76,7 @@ If you are new to ggplot2 you are better off starting with a systematic introduc
7676
[Communication][r4ds-comm] chapters in
7777
[R for Data Science][r4ds]. R for Data Science is designed to
7878
give you a comprehensive introduction to the
79-
[tidyverse](https://www.tidyverse.org), and these two chapters will
79+
[tidyverse](https://tidyverse.org/), and these two chapters will
8080
get you up to speed with the essentials of ggplot2 as quickly as
8181
possible.
8282

@@ -119,4 +119,4 @@ There are two main places to get help with ggplot2:
119119
[r4ds-vis]: https://r4ds.hadley.nz/data-visualize
120120
[r4ds-comm]: https://r4ds.hadley.nz/communication
121121
[oreilly]: https://learning.oreilly.com/videos/data-visualization-in/9781491963661/
122-
[blog]: https://www.tidyverse.org/tags/ggplot2/
122+
[blog]: https://tidyverse.org/tags/ggplot2/

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pak::pak("tidyverse/ggplot2")
3535

3636
## Cheatsheet
3737

38-
<a href="https://github.com/rstudio/cheatsheets/blob/master/data-visualization.pdf"><img src="https://raw.githubusercontent.com/rstudio/cheatsheets/master/pngs/thumbnails/data-visualization-cheatsheet-thumbs.png" width="630" height="252" alt="ggplot2 cheatsheet" /></a>
38+
<a href="https://github.com/rstudio/cheatsheets/blob/main/data-visualization.pdf"><img src="https://raw.githubusercontent.com/rstudio/cheatsheets/main/pngs/thumbnails/data-visualization-cheatsheet-thumbs.png" width="630" height="252" alt="ggplot2 cheatsheet" /></a>
3939

4040
## Usage
4141

@@ -80,8 +80,8 @@ documentation pages. Currently, there are several good places to start:
8080
[Communication](https://r4ds.hadley.nz/communication) chapters in [R
8181
for Data Science](https://r4ds.hadley.nz). R for Data Science is
8282
designed to give you a comprehensive introduction to the
83-
[tidyverse](https://www.tidyverse.org), and these two chapters will
84-
get you up to speed with the essentials of ggplot2 as quickly as
83+
[tidyverse](https://tidyverse.org/), and these two chapters will get
84+
you up to speed with the essentials of ggplot2 as quickly as
8585
possible.
8686

8787
2. If you’d like to take an online course, try [Data Visualization in R
@@ -105,7 +105,7 @@ documentation pages. Currently, there are several good places to start:
105105
graphics specifically tailored to your needs.
106106

107107
6. For articles about announcements and deep-dives you can visit the
108-
[tidyverse blog](https://www.tidyverse.org/tags/ggplot2/).
108+
[tidyverse blog](https://tidyverse.org/tags/ggplot2/).
109109

110110
## Getting help
111111

0 commit comments

Comments
 (0)