Skip to content

V3.3.4 rc #4515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
on:
push:
branches:
- master
pull_request:
branches:
- master
#on:
# push:
# branches:
# - master
# pull_request:
# branches:
# - master

on: [push, pull_request]

name: R-CMD-check

Expand Down
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: ggplot2
Version: 3.3.3.9000
Version: 3.3.4
Title: Create Elegant Data Visualisations Using the Grammar of Graphics
Description: A system for 'declaratively' creating graphics,
based on "The Grammar of Graphics". You provide the data, tell 'ggplot2'
Expand Down Expand Up @@ -274,4 +274,3 @@ Config/Needs/website:
tidyr,
forcats,
tidyverse/tidytemplate

6 changes: 4 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ S3method(fortify,sfg)
S3method(fortify,summary.glht)
S3method(fortify,tbl)
S3method(fortify,tbl_df)
S3method(get_alt_text,ggplot)
S3method(get_alt_text,ggplot_built)
S3method(get_alt_text,gtable)
S3method(ggplot,"function")
S3method(ggplot,default)
S3method(ggplot_add,"NULL")
Expand Down Expand Up @@ -143,7 +146,6 @@ S3method(widthDetails,titleGrob)
S3method(widthDetails,zeroGrob)
export("%+%")
export("%+replace%")
export(":=")
export(.data)
export(.pt)
export(.stroke)
Expand Down Expand Up @@ -274,7 +276,6 @@ export(annotation_raster)
export(arrow)
export(as_label)
export(as_labeller)
export(as_name)
export(autolayer)
export(autoplot)
export(benchplot)
Expand Down Expand Up @@ -392,6 +393,7 @@ export(geom_text)
export(geom_tile)
export(geom_violin)
export(geom_vline)
export(get_alt_text)
export(get_element_tree)
export(gg_dep)
export(ggplot)
Expand Down
186 changes: 100 additions & 86 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,122 +1,147 @@
# ggplot2 (development version)
# ggplot2 3.3.4
This is a larger patch release fixing a huge number of bugs and introduces a
small selection of feature refinements.

* Manual scales now allow named vectors passed to `values` to contain fewer
elements than existing in the data. Elements not present in values will be set
to `NA` (@thomasp85, #3451)

* Remove cross-inheritance of default discrete colour/fill scales and check the
type and aesthetic of function output if `type` is a function
(@thomasp85, #4149)
## Features

* Alt-text can now be added to a plot using the `alt` label, i.e
`+ labs(alt = ...)`. Currently this alt text is not automatically propagated,
but we plan to integrate into Shiny, RMarkdown, and other tools in the future.
(@thomasp85, #4477)

* Add support for the BrailleR package for creating descriptions of the plot
when rendered (@thomasp85, #4459)

* `coord_sf()` now has an argument `default_crs` that specifies the coordinate
reference system (CRS) for non-sf layers and scale/coord limits. This argument
defaults to `NULL`, which means non-sf layers are assumed to be in projected
coordinates, as in prior ggplot2 versions. Setting `default_crs = sf::st_crs(4326)`
provides a simple way to interpret x and y positions as longitude and latitude,
regardless of the CRS used by `coord_sf()`. Authors of extension packages
implementing `stat_sf()`-like functionality are encouraged to look at the source
code of `stat_sf()`'s `compute_group()` function to see how to provide scale-limit
hints to `coord_sf()` (@clauswilke, #3659).

* `ggsave()` now uses ragg to render raster output if ragg is available. It also
handles custom devices that sets a default unit (e.g. `ragg::agg_png`)
correctly (@thomasp85, #4388)

* Fix a bug in the layer implementation that introduced a new state after the
first render which could lead to a different look when rendered the second
time (@thomasp85, #4204)
* `ggsave()` now returns the saved file location invisibly (#3379, @eliocamp).

* The scale arguments `limits`, `breaks`, `minor_breaks`, `labels`, `rescaler`
and `oob` now accept purrr style lambda notation (@teunbrand, #4427). The same
is true for `as_labeller()` (and therefore also `labeller()`)
(@netique, #4188).

* Manual scales now allow named vectors passed to `values` to contain fewer
elements than existing in the data. Elements not present in values will be set
to `NA` (@thomasp85, #3451)

* Make sure `label_bquote()` has access to the calling environment when
evaluating the labels (@thomasp85, #4141)
* Date and datetime position scales support out-of-bounds (oob) arguments to
control how limits affect data outside those limits (@teunbrand, #4199).

## Fixes

* Fix a bug that `after_stat()` and `after_scale()` cannot refer to aesthetics
if it's specified in the plot-global mapping (@yutannihilation, #4260).

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

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

* Extent the range of the line created by `geom_abline()` so that line ending
is not visible for large linewidths (@thomasp85, #4024)

* Fix bug in `geom_dotplot()` where dots would be positioned wrong with
`stackgroups = TRUE` (@thomasp85, #1745)

* Fix calculation of confidence interval for locfit smoothing in `geom_smooth()`
(@topepo, #3806)

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

* Fix a bug in legend justification where justification was lost of the legend
dimensions exceeded the available size (@thomasp85, #3635)

* Fix calculation of confidence interval for locfit smoothing (@topepo, #3806)
* `ggsave()` now sets the default background to match the fill value of the
`plot.background` theme element (@karawoo, #4057)

* Fix bug in `scale_[x|y]_date()` where custom breaks functions that resulted in
fracional dates would get misaligned (@thomasp85, #3965)

* Fix bug in `scale_[x|y]_datetime()` where a specified timezone would be
ignored by the scale (@thomasp85, #4007)

* Using `theme(aspect.ratio = ...)` together with free space in `facet_grid()`
now crrectly throws an error (@thomasp85, #3834)

* Fix a bug in `stat_summary_bin()` where one more than the requested number of
bins would be created (@thomasp85, #3824)

* Fix issue in `sec_axis()` that would throw warnings in the absence of any
secondary breaks (@thomasp85, #4368)
* It is now deprecated to specify `guides(<scale> = FALSE)` or
`scale_*(guide = FALSE)` to remove a guide. Please use
`guides(<scale> = "none")` or `scale_*(guide = "none")` instead
(@yutannihilation, #4094).

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

* Fix bug in `guide_coloursteps()` that would repeat the terminal bins if the
breaks coincided with the limits of the scale (@thomasp85, #4019)

* Extent the range of the line created by `geom_abline()` so that line ending
is not visible for large linewidths (@thomasp85, #4024)

* Make sure that default labels from default mappings doesn't overwrite default
labels from explicit mappings (@thomasp85, #2406)

* `stat_count()` now computes width based on the full dataset instead of per
group (@thomasp85, #2047)

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

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

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

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

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

* Make sure `position_jitter()` creates the same jittering independent of
whether it is called by name or with constructor (@thomasp85, #2507)

* Fix a bug in `position_jitter()` where different jitters would be applied to
different position aesthetics of the same axis (@thomasp85, #2941)

* `ggsave()` now uses ragg to render raster output if ragg is available
(@thomasp85, #4388)

* `coord_sf()` now has an argument `default_crs` that specifies the coordinate
reference system (CRS) for non-sf layers and scale/coord limits. This argument
defaults to the World Geodetic System 1984 (WGS84), which means x and y positions
are interpreted as longitude and latitude. This is a potentially breaking change
for users who use projected coordinates in non-sf layers or in limits. Setting
`default_crs = NULL` recovers the old behavior. Further, authors of extension
packages implementing `stat_sf()`-like functionality are encouraged to look at the
source code of `stat_sf()`'s `compute_group()` function to see how to provide
scale-limit hints to `coord_sf()` (@clauswilke, #3659).

* `ggsave()` now sets the default background to match the fill value of the
`plot.background` theme element (@karawoo, #4057)

* Extended `stat_ecdf()` to calculate the cdf from either x or y instead from y only (@jgjl, #4005).
* Fix a bug in `qplot()` when supplying `c(NA, NA)` as axis limits
(@thomasp85, #4027)

* Remove cross-inheritance of default discrete colour/fill scales and check the
type and aesthetic of function output if `type` is a function
(@thomasp85, #4149)

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

* Updated style for example code (@rjake, #4092)
* Fix bug in `scale_[x|y]_datetime()` where a specified timezone would be
ignored by the scale (@thomasp85, #4007)

* Fix issue in `sec_axis()` that would throw warnings in the absence of any
secondary breaks (@thomasp85, #4368)

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

* `stat_count()` now computes width based on the full dataset instead of per
group (@thomasp85, #2047)

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

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

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

* Fixed a bug in strip assembly when theme has `strip.text = element_blank()`
and plots are faceted with multi-layered strips (@teunbrand, #4384).

* Using `theme(aspect.ratio = ...)` together with free space in `facet_grid()`
now crrectly throws an error (@thomasp85, #3834)

* Fixed a bug in `labeller()` so that `.default` is passed to `as_labeller()`
when labellers are specified by naming faceting variables. (@waltersom, #4031)

* Updated style for example code (@rjake, #4092)

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

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

* Fix a bug that `after_stat()` and `after_scale()` cannot refer to aesthetics
if it's specified in the plot-global mapping (@yutannihilation, #4260).

* `ggsave()` now returns the saved file location invisibly (#3379, @eliocamp).

* The scale arguments `limits`, `breaks`, `minor_breaks`, `labels`, `rescaler`
and `oob` now accept purrr style lambda notation (@teunbrand, #4427).

* `as_labeller()` (and therefore also `labeller()`) now handles functions in
purrr-style lambda notation (@netique, #4188).

# ggplot2 3.3.3
This is a small patch release mainly intended to address changes in R and CRAN.
It further changes the licensing model of ggplot2 to an MIT license.
Expand Down
3 changes: 2 additions & 1 deletion R/annotation-map.r
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ NULL
#' p +
#' coord_sf(
#' crs = st_crs(3347),
#' default_crs = st_crs(4326), # data is provided as long-lat
#' xlim = c(-84, -76),
#' ylim = c(34, 37.2)
#' )
Expand All @@ -53,7 +54,7 @@ NULL
#' data = nc, inherit.aes = FALSE,
#' fill = NA, color = "black", size = 0.1
#' ) +
#' coord_sf(crs = st_crs(3347))
#' coord_sf(crs = st_crs(3347), default_crs = st_crs(4326))
#' }}}
annotation_map <- function(map, ...) {
# Get map input into correct form
Expand Down
40 changes: 19 additions & 21 deletions R/coord-sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
is_free = function() FALSE,

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

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