Skip to content

Commit de5d63f

Browse files
authored
Merge pull request #4515 from tidyverse/v3.3.4-rc
V3.3.4 rc
2 parents 01fe5de + 3c41084 commit de5d63f

40 files changed

+2513
-53198
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
on:
2-
push:
3-
branches:
4-
- master
5-
pull_request:
6-
branches:
7-
- master
1+
#on:
2+
# push:
3+
# branches:
4+
# - master
5+
# pull_request:
6+
# branches:
7+
# - master
8+
9+
on: [push, pull_request]
810

911
name: R-CMD-check
1012

DESCRIPTION

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: ggplot2
2-
Version: 3.3.3.9000
2+
Version: 3.3.4
33
Title: Create Elegant Data Visualisations Using the Grammar of Graphics
44
Description: A system for 'declaratively' creating graphics,
55
based on "The Grammar of Graphics". You provide the data, tell 'ggplot2'
@@ -274,4 +274,3 @@ Config/Needs/website:
274274
tidyr,
275275
forcats,
276276
tidyverse/tidytemplate
277-

NAMESPACE

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ S3method(fortify,sfg)
4646
S3method(fortify,summary.glht)
4747
S3method(fortify,tbl)
4848
S3method(fortify,tbl_df)
49+
S3method(get_alt_text,ggplot)
50+
S3method(get_alt_text,ggplot_built)
51+
S3method(get_alt_text,gtable)
4952
S3method(ggplot,"function")
5053
S3method(ggplot,default)
5154
S3method(ggplot_add,"NULL")
@@ -143,7 +146,6 @@ S3method(widthDetails,titleGrob)
143146
S3method(widthDetails,zeroGrob)
144147
export("%+%")
145148
export("%+replace%")
146-
export(":=")
147149
export(.data)
148150
export(.pt)
149151
export(.stroke)
@@ -274,7 +276,6 @@ export(annotation_raster)
274276
export(arrow)
275277
export(as_label)
276278
export(as_labeller)
277-
export(as_name)
278279
export(autolayer)
279280
export(autoplot)
280281
export(benchplot)
@@ -392,6 +393,7 @@ export(geom_text)
392393
export(geom_tile)
393394
export(geom_violin)
394395
export(geom_vline)
396+
export(get_alt_text)
395397
export(get_element_tree)
396398
export(gg_dep)
397399
export(ggplot)

NEWS.md

Lines changed: 100 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,147 @@
1-
# ggplot2 (development version)
1+
# ggplot2 3.3.4
2+
This is a larger patch release fixing a huge number of bugs and introduces a
3+
small selection of feature refinements.
24

3-
* Manual scales now allow named vectors passed to `values` to contain fewer
4-
elements than existing in the data. Elements not present in values will be set
5-
to `NA` (@thomasp85, #3451)
6-
7-
* Remove cross-inheritance of default discrete colour/fill scales and check the
8-
type and aesthetic of function output if `type` is a function
9-
(@thomasp85, #4149)
5+
## Features
6+
7+
* Alt-text can now be added to a plot using the `alt` label, i.e
8+
`+ labs(alt = ...)`. Currently this alt text is not automatically propagated,
9+
but we plan to integrate into Shiny, RMarkdown, and other tools in the future.
10+
(@thomasp85, #4477)
1011

1112
* Add support for the BrailleR package for creating descriptions of the plot
1213
when rendered (@thomasp85, #4459)
14+
15+
* `coord_sf()` now has an argument `default_crs` that specifies the coordinate
16+
reference system (CRS) for non-sf layers and scale/coord limits. This argument
17+
defaults to `NULL`, which means non-sf layers are assumed to be in projected
18+
coordinates, as in prior ggplot2 versions. Setting `default_crs = sf::st_crs(4326)`
19+
provides a simple way to interpret x and y positions as longitude and latitude,
20+
regardless of the CRS used by `coord_sf()`. Authors of extension packages
21+
implementing `stat_sf()`-like functionality are encouraged to look at the source
22+
code of `stat_sf()`'s `compute_group()` function to see how to provide scale-limit
23+
hints to `coord_sf()` (@clauswilke, #3659).
24+
25+
* `ggsave()` now uses ragg to render raster output if ragg is available. It also
26+
handles custom devices that sets a default unit (e.g. `ragg::agg_png`)
27+
correctly (@thomasp85, #4388)
1328

14-
* Fix a bug in the layer implementation that introduced a new state after the
15-
first render which could lead to a different look when rendered the second
16-
time (@thomasp85, #4204)
29+
* `ggsave()` now returns the saved file location invisibly (#3379, @eliocamp).
30+
31+
* The scale arguments `limits`, `breaks`, `minor_breaks`, `labels`, `rescaler`
32+
and `oob` now accept purrr style lambda notation (@teunbrand, #4427). The same
33+
is true for `as_labeller()` (and therefore also `labeller()`)
34+
(@netique, #4188).
35+
36+
* Manual scales now allow named vectors passed to `values` to contain fewer
37+
elements than existing in the data. Elements not present in values will be set
38+
to `NA` (@thomasp85, #3451)
1739

18-
* Make sure `label_bquote()` has access to the calling environment when
19-
evaluating the labels (@thomasp85, #4141)
40+
* Date and datetime position scales support out-of-bounds (oob) arguments to
41+
control how limits affect data outside those limits (@teunbrand, #4199).
42+
43+
## Fixes
44+
45+
* Fix a bug that `after_stat()` and `after_scale()` cannot refer to aesthetics
46+
if it's specified in the plot-global mapping (@yutannihilation, #4260).
2047

2148
* Fix bug in `annotate_logticks()` that would cause an error when used together
2249
with `coord_flip()` (@thomasp85, #3954)
2350

24-
* Fix a bug in `guide_bins()` where keys would disappear if the guide was
25-
reversed (@thomasp85, #4210)
51+
* Fix a bug in `geom_abline()` that resulted in `intercept` not being subjected
52+
to the transformation of the y scale (@thomasp85, #3741)
53+
54+
* Extent the range of the line created by `geom_abline()` so that line ending
55+
is not visible for large linewidths (@thomasp85, #4024)
56+
57+
* Fix bug in `geom_dotplot()` where dots would be positioned wrong with
58+
`stackgroups = TRUE` (@thomasp85, #1745)
59+
60+
* Fix calculation of confidence interval for locfit smoothing in `geom_smooth()`
61+
(@topepo, #3806)
2662

2763
* Fix bug in `geom_text()` where `"outward"` and `"inward"` justification for
2864
some `angle` values was reversed (@aphalo, #4169, #4447)
2965

30-
* Fix a bug in legend justification where justification was lost of the legend
31-
dimensions exceeded the available size (@thomasp85, #3635)
32-
33-
* Fix calculation of confidence interval for locfit smoothing (@topepo, #3806)
66+
* `ggsave()` now sets the default background to match the fill value of the
67+
`plot.background` theme element (@karawoo, #4057)
3468

35-
* Fix bug in `scale_[x|y]_date()` where custom breaks functions that resulted in
36-
fracional dates would get misaligned (@thomasp85, #3965)
37-
38-
* Fix bug in `scale_[x|y]_datetime()` where a specified timezone would be
39-
ignored by the scale (@thomasp85, #4007)
40-
41-
* Using `theme(aspect.ratio = ...)` together with free space in `facet_grid()`
42-
now crrectly throws an error (@thomasp85, #3834)
43-
44-
* Fix a bug in `stat_summary_bin()` where one more than the requested number of
45-
bins would be created (@thomasp85, #3824)
46-
47-
* Fix issue in `sec_axis()` that would throw warnings in the absence of any
48-
secondary breaks (@thomasp85, #4368)
69+
* It is now deprecated to specify `guides(<scale> = FALSE)` or
70+
`scale_*(guide = FALSE)` to remove a guide. Please use
71+
`guides(<scale> = "none")` or `scale_*(guide = "none")` instead
72+
(@yutannihilation, #4094).
4973

50-
* Fix a bug in `geom_abline()` that resulted in `intercept` not being subjected
51-
to the transformation of the y scale (@thomasp85, #3741)
74+
* Fix a bug in `guide_bins()` where keys would disappear if the guide was
75+
reversed (@thomasp85, #4210)
5276

5377
* Fix bug in `guide_coloursteps()` that would repeat the terminal bins if the
5478
breaks coincided with the limits of the scale (@thomasp85, #4019)
55-
56-
* Extent the range of the line created by `geom_abline()` so that line ending
57-
is not visible for large linewidths (@thomasp85, #4024)
5879

5980
* Make sure that default labels from default mappings doesn't overwrite default
6081
labels from explicit mappings (@thomasp85, #2406)
61-
62-
* `stat_count()` now computes width based on the full dataset instead of per
63-
group (@thomasp85, #2047)
6482

6583
* Fix bug in `labeller()` where parsing was turned off if `.multiline = FALSE`
6684
(@thomasp85, #4084)
6785

68-
* Fix a bug in `qplot()` when supplying `c(NA, NA)` as axis limits
69-
(@thomasp85, #4027)
86+
* Make sure `label_bquote()` has access to the calling environment when
87+
evaluating the labels (@thomasp85, #4141)
7088

71-
* Fix bug in `geom_dotplot()` where dots would be positioned wrong with
72-
`stackgroups = TRUE` (@thomasp85, #1745)
89+
* Fix a bug in the layer implementation that introduced a new state after the
90+
first render which could lead to a different look when rendered the second
91+
time (@thomasp85, #4204)
7392

74-
* Make sure position_jitter creates the same jittering independent of whether it
75-
is called by name or with constructor (@thomasp85, #2507)
93+
* Fix a bug in legend justification where justification was lost of the legend
94+
dimensions exceeded the available size (@thomasp85, #3635)
7695

7796
* Fix a bug in `position_dodge2()` where `NA` values in thee data would cause an
7897
error (@thomasp85, #2905)
7998

99+
* Make sure `position_jitter()` creates the same jittering independent of
100+
whether it is called by name or with constructor (@thomasp85, #2507)
101+
80102
* Fix a bug in `position_jitter()` where different jitters would be applied to
81103
different position aesthetics of the same axis (@thomasp85, #2941)
82-
83-
* `ggsave()` now uses ragg to render raster output if ragg is available
84-
(@thomasp85, #4388)
85104

86-
* `coord_sf()` now has an argument `default_crs` that specifies the coordinate
87-
reference system (CRS) for non-sf layers and scale/coord limits. This argument
88-
defaults to the World Geodetic System 1984 (WGS84), which means x and y positions
89-
are interpreted as longitude and latitude. This is a potentially breaking change
90-
for users who use projected coordinates in non-sf layers or in limits. Setting
91-
`default_crs = NULL` recovers the old behavior. Further, authors of extension
92-
packages implementing `stat_sf()`-like functionality are encouraged to look at the
93-
source code of `stat_sf()`'s `compute_group()` function to see how to provide
94-
scale-limit hints to `coord_sf()` (@clauswilke, #3659).
95-
96-
* `ggsave()` now sets the default background to match the fill value of the
97-
`plot.background` theme element (@karawoo, #4057)
98-
99-
* Extended `stat_ecdf()` to calculate the cdf from either x or y instead from y only (@jgjl, #4005).
105+
* Fix a bug in `qplot()` when supplying `c(NA, NA)` as axis limits
106+
(@thomasp85, #4027)
107+
108+
* Remove cross-inheritance of default discrete colour/fill scales and check the
109+
type and aesthetic of function output if `type` is a function
110+
(@thomasp85, #4149)
100111

101-
* Fixed a bug in `labeller()` so that `.default` is passed to `as_labeller()`
102-
when labellers are specified by naming faceting variables. (@waltersom, #4031)
112+
* Fix bug in `scale_[x|y]_date()` where custom breaks functions that resulted in
113+
fracional dates would get misaligned (@thomasp85, #3965)
103114

104-
* Updated style for example code (@rjake, #4092)
115+
* Fix bug in `scale_[x|y]_datetime()` where a specified timezone would be
116+
ignored by the scale (@thomasp85, #4007)
117+
118+
* Fix issue in `sec_axis()` that would throw warnings in the absence of any
119+
secondary breaks (@thomasp85, #4368)
105120

106-
* Only drop groups in `stat_ydensity()` when there are fewer than two data points and throw a warning (@andrewwbutler, #4111).
121+
* `stat_bin()`'s computed variable `width` is now documented (#3522).
122+
123+
* `stat_count()` now computes width based on the full dataset instead of per
124+
group (@thomasp85, #2047)
107125

108-
* It is now deprecated to specify `guides(<scale> = FALSE)` or
109-
`scale_*(guide = FALSE)` to remove a guide. Please use
110-
`guides(<scale> = "none")` or `scale_*(guide = "none")` instead
111-
(@yutannihilation, #4094).
126+
* Extended `stat_ecdf()` to calculate the cdf from either x or y instead from y
127+
only (@jgjl, #4005)
112128

113-
* Date and datetime position scales support out-of-bounds (oob) arguments to
114-
control how limits affect data outside those limits (@teunbrand, #4199).
129+
* Fix a bug in `stat_summary_bin()` where one more than the requested number of
130+
bins would be created (@thomasp85, #3824)
115131

116-
* `stat_bin()`'s computed variable `width` is now documented (#3522).
132+
* Only drop groups in `stat_ydensity()` when there are fewer than two data
133+
points and throw a warning (@andrewwbutler, #4111).
117134

118135
* Fixed a bug in strip assembly when theme has `strip.text = element_blank()`
119136
and plots are faceted with multi-layered strips (@teunbrand, #4384).
137+
138+
* Using `theme(aspect.ratio = ...)` together with free space in `facet_grid()`
139+
now crrectly throws an error (@thomasp85, #3834)
140+
141+
* Fixed a bug in `labeller()` so that `.default` is passed to `as_labeller()`
142+
when labellers are specified by naming faceting variables. (@waltersom, #4031)
143+
144+
* Updated style for example code (@rjake, #4092)
120145

121146
* ggplot2 now requires R >= 3.3 (#4247).
122147

@@ -127,17 +152,6 @@
127152
* Improved error with hint when piping a `ggplot` object into a facet function
128153
(#4379, @mitchelloharawild).
129154

130-
* Fix a bug that `after_stat()` and `after_scale()` cannot refer to aesthetics
131-
if it's specified in the plot-global mapping (@yutannihilation, #4260).
132-
133-
* `ggsave()` now returns the saved file location invisibly (#3379, @eliocamp).
134-
135-
* The scale arguments `limits`, `breaks`, `minor_breaks`, `labels`, `rescaler`
136-
and `oob` now accept purrr style lambda notation (@teunbrand, #4427).
137-
138-
* `as_labeller()` (and therefore also `labeller()`) now handles functions in
139-
purrr-style lambda notation (@netique, #4188).
140-
141155
# ggplot2 3.3.3
142156
This is a small patch release mainly intended to address changes in R and CRAN.
143157
It further changes the licensing model of ggplot2 to an MIT license.

R/annotation-map.r

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ NULL
4242
#' p +
4343
#' coord_sf(
4444
#' crs = st_crs(3347),
45+
#' default_crs = st_crs(4326), # data is provided as long-lat
4546
#' xlim = c(-84, -76),
4647
#' ylim = c(34, 37.2)
4748
#' )
@@ -53,7 +54,7 @@ NULL
5354
#' data = nc, inherit.aes = FALSE,
5455
#' fill = NA, color = "black", size = 0.1
5556
#' ) +
56-
#' coord_sf(crs = st_crs(3347))
57+
#' coord_sf(crs = st_crs(3347), default_crs = st_crs(4326))
5758
#' }}}
5859
annotation_map <- function(map, ...) {
5960
# Get map input into correct form

R/coord-sf.R

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
268268
is_free = function() FALSE,
269269

270270
# for regular geoms (such as geom_path, geom_polygon, etc.), CoordSf is non-linear
271-
is_linear = function() FALSE,
271+
# if the default_crs option is being used, i.e., not set to NULL
272+
is_linear = function(self) is.null(self$get_default_crs()),
272273

273274
distance = function(self, x, y, panel_params) {
274275
d <- self$backtransform_range(panel_params)
@@ -588,29 +589,26 @@ calc_limits_bbox <- function(method, xlim, ylim, crs, default_crs) {
588589
#' be projected before plotting. If not specified, will use the CRS defined
589590
#' in the first sf layer of the plot.
590591
#' @param default_crs The default CRS to be used for non-sf layers (which
591-
#' don't carry any CRS information) and scale limits. If not specified, this
592-
#' defaults to the World Geodetic System 1984 (WGS84), which means x and y
593-
#' positions are interpreted as longitude and latitude, respectively. If
594-
#' set to `NULL`, uses the setting for `crs`, which means that then all
592+
#' don't carry any CRS information) and scale limits. The default value of
593+
#' `NULL` means that the setting for `crs` is used. This implies that all
595594
#' non-sf layers and scale limits are assumed to be specified in projected
596-
#' coordinates.
595+
#' coordinates. A useful alternative setting is `default_crs = sf::st_crs(4326)`,
596+
#' which means x and y positions are interpreted as longitude and latitude,
597+
#' respectively, in the World Geodetic System 1984 (WGS84).
597598
#' @param xlim,ylim Limits for the x and y axes. These limits are specified
598-
#' in the units of the default CRS. To specify limits in projected coordinates,
599-
#' set `default_crs = NULL`. How limit specifications translate into the exact
599+
#' in the units of the default CRS. By default, this means projected coordinates
600+
#' (`default_crs = NULL`). How limit specifications translate into the exact
600601
#' region shown on the plot can be confusing when non-linear or rotated coordinate
601-
#' systems are used. First, different methods can be preferable under different
602-
#' conditions. See parameter `lims_method` for details. Second, specifying limits
603-
#' along only one direction can affect the automatically generated limits along the
604-
#' other direction. Therefore, it is best to always specify limits for both x and y.
605-
#' Third, specifying limits via position scales or `xlim()`/`ylim()` is strongly
606-
#' discouraged, as it can result in data points being dropped from the plot even
607-
#' though they would be visible in the final plot region. Finally, specifying limits
608-
#' that cross the international date boundary is not possible with WGS84 as the default
609-
#' crs. All these issues can be avoided by working in projected coordinates,
610-
#' via `default_crs = NULL`, but at the cost of having to provide less intuitive
611-
#' numeric values for the limit parameters.
602+
#' systems are used as the default crs. First, different methods can be preferable
603+
#' under different conditions. See parameter `lims_method` for details. Second,
604+
#' specifying limits along only one direction can affect the automatically generated
605+
#' limits along the other direction. Therefore, it is best to always specify limits
606+
#' for both x and y. Third, specifying limits via position scales or `xlim()`/`ylim()`
607+
#' is strongly discouraged, as it can result in data points being dropped from the plot even
608+
#' though they would be visible in the final plot region.
612609
#' @param lims_method Method specifying how scale limits are converted into
613-
#' limits on the plot region. For a very non-linear CRS (e.g., a perspective centered
610+
#' limits on the plot region. Has no effect when `default_crs = NULL`.
611+
#' For a very non-linear CRS (e.g., a perspective centered
614612
#' around the North pole), the available methods yield widely differing results, and
615613
#' you may want to try various options. Methods currently implemented include `"cross"`
616614
#' (the default), `"box"`, `"orthogonal"`, and `"geometry_bbox"`. For method `"cross"`,
@@ -655,7 +653,7 @@ calc_limits_bbox <- function(method, xlim, ylim, crs, default_crs) {
655653
#' @export
656654
#' @rdname ggsf
657655
coord_sf <- function(xlim = NULL, ylim = NULL, expand = TRUE,
658-
crs = NULL, default_crs = sf::st_crs(4326),
656+
crs = NULL, default_crs = NULL,
659657
datum = sf::st_crs(4326),
660658
label_graticule = waiver(),
661659
label_axes = waiver(), lims_method = c("cross", "box", "orthogonal", "geometry_bbox"),

0 commit comments

Comments
 (0)