Skip to content

Commit cd6bff1

Browse files
committed
resolve merge conflict
Merge branch 'main' into centralise_layer_arg_docs # Conflicts: # R/utilities-help.R # man/geom_bar.Rd # man/geom_boxplot.Rd # man/geom_density.Rd # man/geom_histogram.Rd # man/geom_linerange.Rd # man/geom_path.Rd # man/geom_ribbon.Rd # man/geom_smooth.Rd # man/geom_violin.Rd # man/stat_summary.Rd
2 parents 40eec09 + 194d8c9 commit cd6bff1

23 files changed

+100
-49
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", , "hadley@posit.co", role = "aut",
66
comment = c(ORCID = "0000-0003-4757-117X")),

NEWS.md

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

3+
* `get_layer_data()` and `get_layer_grob()` now accept layer names as index
4+
(@lgaborini, #6724)
5+
6+
# ggplot2 4.0.1
7+
8+
This is a smaller patch release focussed on fixing regressions from 4.0.0 and
9+
polishing the recent features.
10+
11+
## Bug fixes
12+
313
* Fixed regression where `geom_area()` didn't draw panels with single groups
414
when `stat = "align"` (@teunbrand, #6680)
515
* Fixed regression where `position_stack(vjust)` was ignored when there are
616
only single groups (#6692)
717
* 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)
1318
* Fixed bug where `stat_bin(boundary)` was ignored (#6682).
1419
* `geom_text()` and `geom_label()` accept expressions as the `label` aesthetic
1520
(@teunbrand, #6638)
1621
* Fixed regression where `draw_key_rect()` stopped using `fill` colours
1722
(@mitchelloharawild, #6609).
1823
* Fixed regression where `scale_{x,y}_*()` threw an error when an expression
1924
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)
2325
* Fixed regression where the first (unnamed) argument to colour/fill scales was
2426
not passed as the `name` argument (@teunbrand, #6623)
2527
* Fixed issue where vectorised `arrow()`s caused errors in drawing the
@@ -28,10 +30,21 @@
2830
insistently. Now they contribute only as fallback labels (@teunbrand, #6616)
2931
* Fixed regression where empty arguments to colour/fill scale caused errors
3032
(@jmbarbone, #6710)
33+
* Fixed axis misplacement in `coor_radial()` when labels are blank (@teunbrand, #6574)
34+
35+
## Improvements
36+
37+
* Improved palette fallback mechanism in scales (@teunbrand, #6669).
38+
* Allow `stat` in `geom_hline`, `geom_vline`, and `geom_abline`. (@sierrajohnson, #6559)
39+
* `stat_boxplot()` treats `width` as an optional aesthetic (@Yunuuuu, #6575)
3140
* The `theme(panel.widths, panel.heights)` setting attempts to preserve the
3241
plot's aspect ratio when only one of the two settings is given, and the plot
3342
has a single panel (@teunbrand, #6701).
34-
* Fixed axis misplacement in `coor_radial()` when labels are blank (@teunbrand, #6574)
43+
* Logical values for the linetype aesthetic will be interpreted numerically,
44+
so that `linetype = FALSE` becomes 0/'blank' and `linetype = TRUE` becomes
45+
1/'solid' (@teunbrand, #6641)
46+
* Out-of-bounds datapoints used as padding by `stat_align()` now get removed
47+
silently rather than verbosely (@teunbrand, #6667)
3548

3649
# ggplot2 4.0.0
3750

R/facet-wrap.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ NULL
4040
#' `"all_x"` and `"all_y"` will draw the respective axes at the interior
4141
#' panels too, whereas `"all"` will draw all axes at all panels.
4242
#' @param axis.labels Determines whether to draw labels for interior axes when
43-
#' the scale is fixed and the `axis` argument is not `"margins"`. When
43+
#' the scale is fixed and the `axes` argument is not `"margins"`. When
4444
#' `"all"` (default), all interior axes get labels. When `"margins"`, only
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

R/layer.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
#' See the *Orientation* section for more detail.
126126
#'
127127
#' @section Orientation:
128-
#' This geom treats each axis differently and, thus, can thus have two
128+
#' This geom treats each axis differently and, thus, can have two
129129
#' orientations. Often the orientation is easy to deduce from a combination of
130130
#' the given mappings and the types of positional scales in use. Thus, ggplot2
131131
#' will by default try to guess which orientation the layer should have. Under
@@ -1054,10 +1054,8 @@ normalise_label <- function(label) {
10541054
return(NULL)
10551055
}
10561056
if (obj_is_list(label)) {
1057-
# Ensure that each element in the list has length 1
1057+
# Ensure no elements are empty
10581058
label[lengths(label) == 0] <- ""
1059-
truncate <- !vapply(label, is.call, logical(1)) # Don't mess with call/formula
1060-
label[truncate] <- lapply(label[truncate], `[`, 1)
10611059
}
10621060
if (is.expression(label)) {
10631061
# Classed expressions, when converted to lists, retain their class.

R/plot-build.R

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#' layer. These are useful for tests.
1212
#'
1313
#' @param plot ggplot object
14-
#' @param i An integer. In `get_layer_data()`, the data to return (in the order added to the
14+
#' @param i An integer or a name of a layer. In `get_layer_data()`, the data to return (in the order added to the
1515
#' plot). In `get_layer_grob()`, the grob to return (in the order added to the
16-
#' plot). In `get_panel_scales()`, the row of a facet to return scales for.
16+
#' plot). In `get_panel_scales()` (only integers allowed), the row of a facet to return scales for.
1717
#' @param j An integer. In `get_panel_scales()`, the column of a facet to return
1818
#' scales for.
1919
#' @param ... Not currently in use.
@@ -142,8 +142,15 @@ build_ggplot <- S7::method(ggplot_build, class_ggplot) <- function(plot, ...) {
142142
#' @export
143143
#' @rdname ggplot_build
144144
get_layer_data <- function(plot = get_last_plot(), i = 1L) {
145-
ggplot_build(plot)@data[[i]]
145+
b <- ggplot_build(plot)
146+
idx <- vec_as_location2(
147+
i = i,
148+
n = vec_size(b@plot@layers),
149+
names = names(b@plot@layers)
150+
)
151+
b@data[[idx]]
146152
}
153+
147154
#' @export
148155
#' @rdname ggplot_build
149156
layer_data <- get_layer_data
@@ -171,7 +178,12 @@ layer_scales <- get_panel_scales
171178
get_layer_grob <- function(plot = get_last_plot(), i = 1L) {
172179
b <- ggplot_build(plot)
173180

174-
b@plot@layers[[i]]$draw_geom(b@data[[i]], b@layout)
181+
idx <- vec_as_location2(
182+
i = i,
183+
n = vec_size(b@plot@layers),
184+
names = names(b@plot@layers)
185+
)
186+
b@plot@layers[[idx]]$draw_geom(b@data[[idx]], b@layout)
175187
}
176188

177189
#' @export

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

cran-comments.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
This is a major release of ggplot2. Among other things it includes an adaption
2-
of S7 for all the S3 classes and methods that were currently in use.
3-
Unfortunately such a change is not without issue with the number of reverse
4-
dependencies that ggplot2 has as many packages wrongfully checks the internals
5-
of ggplot2 objects in their tests.
1+
This is a patch release fixing a range of regressions reported after the 4.0.0
2+
release. While no breaking changes in the API we did detect a few packages that
3+
breaks with this release due to either making assumptions about ggplot2 internal
4+
behaviour, or requiring documentation updates that can only happen after release
5+
of 4.0.1
66

7-
Because of this you should expect a larger than usual number of breaking
8-
packages. We have been very diligent to reach out to all maintainers over the
9-
last 2-3 months and provided resolutions but breakages are still to be expected.
7+
The packages are:
8+
- adproplus: https://github.com/henry-heppe/adproclus/issues/3
9+
- ggsurveillance: https://github.com/biostats-dev/ggsurveillance/issues/1
10+
- ggformula: https://github.com/ProjectMOSAIC/ggformula/issues/187
11+
- ggside: https://github.com/jtlandis/ggside/issues/71
12+
13+
They have all been notified in advance of this submission

man/facet_wrap.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_bar.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)