Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c491801
Remove leading space in document (#4329)
cuixueqin Jan 26, 2021
2389828
Fix deprecated 'brew cask' calls
jimhester Jan 28, 2021
6e987ed
Update vdiffr cases for sf 0.9-7 and fix forbidden "brew cask" (#4311)
yutannihilation Jan 30, 2021
dbd7d79
Improve docs for geom_contour as discussed in issue #4324 (#4325)
dmurdoch Jan 30, 2021
4555055
Fix scale_color_discrete documentation link (#4363)
jashapiro Mar 3, 2021
be50f53
Use rlang::check_installed() (#4375)
malcolmbarrett Mar 18, 2021
199be05
transform all the sfc columns independently (#4382)
yutannihilation Mar 19, 2021
1d8483a
Improve error when piping plots into facets (#4385)
mitchelloharawild Mar 22, 2021
eca0862
Fix blank strip text with multilayered strips (#4384)
teunbrand Mar 22, 2021
de0b9e3
Fix pkgdown navbar (#4378)
yutannihilation Mar 24, 2021
ed2f8e8
Fix `after_scale()` with plot mappings (#4265)
yutannihilation Mar 25, 2021
a835207
Add missing US spellings for “scale_grey” (#4299)
klmr Mar 25, 2021
2d54ee9
Change help message in geom_bindot() to not include reference to non-…
orrymr Mar 25, 2021
36d5b07
Make guide_bins() respect override.aes (#4104)
yutannihilation Mar 25, 2021
4e88c25
Ignore missing facet specs (#4383)
yutannihilation Mar 25, 2021
80fef9c
Move an unreleased item to development version (#4380)
yutannihilation Mar 25, 2021
bf8786d
Show a function name instead of function call on ggsave's doc (#4371)
yutannihilation Mar 25, 2021
241b7c5
Move the check on misuse of data.frame() to tests (#3758)
yutannihilation Mar 26, 2021
a878bdb
Axis text outside panel with inward ticks (#4392)
teunbrand Apr 8, 2021
23baab0
Adds return value for ggsave (#4396)
eliocamp Apr 8, 2021
0990114
Allow scale_{colour/fill}_ordinal() to be configured via new ggplot2.…
cpsievert Apr 8, 2021
a9b3b17
Add full support for ragg (#4388)
thomasp85 Apr 9, 2021
a9cc097
Use Ubuntu 18.04 (#4406)
yutannihilation Apr 9, 2021
15d38fb
Make sure jitter is only calculated once (#4403)
thomasp85 Apr 9, 2021
aafcac3
Update geom-text.r (#4389)
larspijnappel Apr 9, 2021
15ce4a9
Allow NA values in position_dodge2 (#4408)
thomasp85 Apr 12, 2021
8856671
Move seed setup to setup_params() from the constructor (#4413)
thomasp85 Apr 13, 2021
d26b19c
Revert "Add missing US spellings for “scale_grey” (#4299)" (#4411)
thomasp85 Apr 13, 2021
668a51e
Ensure correct positioning of dots in geom_dotplot (#4417)
thomasp85 Apr 14, 2021
1023861
Only apply limits if they are not NA (#4419)
thomasp85 Apr 15, 2021
9cfb0b3
Make sure that expressions are reencoded as expressions when collapse…
thomasp85 Apr 15, 2021
f014bbd
move width computation to `setup_params()` (#4416)
thomasp85 Apr 15, 2021
397c1c7
Mark labels from default mappings and overwrite them if possible (#4414)
thomasp85 Apr 15, 2021
6cf1370
FAQ vignettes for ggplot2 (#4404)
mine-cetinkaya-rundel Apr 16, 2021
5274088
fix case
thomasp85 Apr 16, 2021
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
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ visual_test
^vignettes/profiling.Rmd$
^cran-comments\.md$
^LICENSE\.md$
^vignettes/articles$
18 changes: 9 additions & 9 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: R-CMD-check

# Increment this version when we want to clear cache
env:
cache-version: v4
cache-version: v6

jobs:
R-CMD-check:
Expand All @@ -24,12 +24,12 @@ jobs:
config:
- {os: windows-latest, r: '4.0', vdiffr: true, xref: true}
- {os: macOS-latest, r: '4.0', vdiffr: true, xref: true}
- {os: ubuntu-16.04, r: 'devel', vdiffr: false, xref: true}
- {os: ubuntu-16.04, r: '4.0', vdiffr: true, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: '3.6', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: '3.5', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: '3.4', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: '3.3', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- {os: ubuntu-18.04, r: 'devel', vdiffr: false, xref: true}
- {os: ubuntu-18.04, r: '4.0', vdiffr: true, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: '3.6', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: '3.5', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: '3.4', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: '3.3', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
Expand Down Expand Up @@ -72,13 +72,13 @@ jobs:
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "16.04"))')
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "18.04"))')

- name: Install system dependencies on macOS
if: runner.os == 'macOS'
run: |
# XQuartz is needed by vdiffr
brew cask install xquartz
brew install xquartz

# Use only binary packages
echo 'options(pkgType = "binary")' >> ~/.Rprofile
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE, type = "binary")
remotes::install_github("tidyverse/tidytemplate")
remotes::install_dev("pkgdown")
remotes::install_github("tidyverse/tidytemplate", type = "binary")
remotes::install_dev("pkgdown", type = "binary")
shell: Rscript {0}

- name: Install package
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Install system dependencies on macOS
run: |
# XQuartz is needed by vdiffr
brew cask install xquartz
brew install xquartz

- name: Install dependencies
run: |
Expand Down
8 changes: 7 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@ Imports:
isoband,
MASS,
mgcv,
rlang (>= 0.3.0),
rlang (>= 0.4.10),
scales (>= 0.5.0),
stats,
tibble,
withr (>= 2.0.0)
Suggests:
covr,
ragg,
dplyr,
ggplot2movies,
hexbin,
Hmisc,
interp,
knitr,
lattice,
mapproj,
Expand Down Expand Up @@ -267,3 +269,7 @@ VignetteBuilder: knitr
RoxygenNote: 7.1.1
Roxygen: list(markdown = TRUE)
Encoding: UTF-8
Config/Needs/website:
ggtext,
tidyr,
forcats
66 changes: 56 additions & 10 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
# ggplot2 (development version)


* 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)

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

* 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_dodge2()` where `NA` values in thee data would cause an
error (@thomasp85, #2905)

* 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)

Expand All @@ -22,8 +60,23 @@

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

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

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

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

* 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).

# 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 All @@ -34,6 +87,9 @@ It further changes the licensing model of ggplot2 to an MIT license.

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

* Fixed a bug that `guide_bins()` mistakenly ignore `override.aes` argument
(@yutannihilation, #4085).

# ggplot2 3.3.2
This is a small release focusing on fixing regressions introduced in 3.3.1.

Expand All @@ -42,16 +98,6 @@ This is a small release focusing on fixing regressions introduced in 3.3.1.

* `annotation_raster()` adds support for native rasters. For large rasters,
native rasters render significantly faster than arrays (@kent37, #3388)

* `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).

* Facet strips now have dedicated position-dependent theme elements
(`strip.text.x.top`, `strip.text.x.bottom`, `strip.text.y.left`,
Expand Down
1 change: 1 addition & 0 deletions R/coord-map.r
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ CoordMap <- ggproto("CoordMap", Coord,


mproject <- function(coord, x, y, orientation) {
check_installed("mapproj", reason = "for `coord_map()`")
suppressWarnings(mapproj::mapproject(x, y,
projection = coord$projection,
parameters = coord$params,
Expand Down
4 changes: 3 additions & 1 deletion R/coord-sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
return(layer_data)
}

sf::st_transform(layer_data, params$crs)
idx <- vapply(layer_data, inherits, what = "sfc", FUN.VALUE = logical(1L))
layer_data[idx] <- lapply(layer_data[idx], sf::st_transform, crs = params$crs)
layer_data
})
},

Expand Down
21 changes: 16 additions & 5 deletions R/facet-.r
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,7 @@ df.grid <- function(a, b) {
# facetting variables.

as_facets_list <- function(x) {
if (inherits(x, "uneval")) {
abort("Please use `vars()` to supply facet variables")
}
x <- validate_facets(x)
if (is_quosures(x)) {
x <- quos_auto_name(x)
return(list(x))
Expand Down Expand Up @@ -315,11 +313,24 @@ as_facets_list <- function(x) {
x
}

validate_facets <- function(x) {
if (inherits(x, "uneval")) {
abort("Please use `vars()` to supply facet variables")
}
if (inherits(x, "ggplot")) {
abort(
"Please use `vars()` to supply facet variables\nDid you use %>% instead of +?"
)
}
x
}


# Flatten a list of quosures objects to a quosures object, and compact it
compact_facets <- function(x) {
x <- flatten_if(x, is_list)
null <- vapply(x, quo_is_null, logical(1))
new_quosures(x[!null])
null_or_missing <- vapply(x, function(x) quo_is_null(x) || quo_is_missing(x), logical(1))
new_quosures(x[!null_or_missing])
}

# Compatibility with plyr::as.quoted()
Expand Down
9 changes: 8 additions & 1 deletion R/facet-grid-.r
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,14 @@ grid_as_facets_list <- function(rows, cols) {
is_rows_vars <- is.null(rows) || is_quosures(rows)
if (!is_rows_vars) {
if (!is.null(cols)) {
abort("`rows` must be `NULL` or a `vars()` list if `cols` is a `vars()` list")
msg <- "`rows` must be `NULL` or a `vars()` list if `cols` is a `vars()` list"
if(inherits(rows, "ggplot")) {
msg <- paste0(
msg, "\n",
"Did you use %>% instead of +?"
)
}
abort(msg)
}
# For backward-compatibility
facets_list <- as_facets_list(rows)
Expand Down
13 changes: 7 additions & 6 deletions R/facet-wrap.r
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ facet_wrap <- function(facets, nrow = NULL, ncol = NULL, scales = "fixed",
x = any(scales %in% c("free_x", "free")),
y = any(scales %in% c("free_y", "free"))
)

# Check for deprecated labellers
labeller <- check_labeller(labeller)

# Flatten all facets dimensions into a single one
facets <- wrap_as_facets_list(facets)

if (!is.null(switch)) {
.Deprecated("strip.position", old = "switch")
strip.position <- if (switch == "x") "bottom" else "left"
Expand All @@ -102,12 +109,6 @@ facet_wrap <- function(facets, nrow = NULL, ncol = NULL, scales = "fixed",
ncol <- sanitise_dim(ncol)
}

# Check for deprecated labellers
labeller <- check_labeller(labeller)

# Flatten all facets dimensions into a single one
facets <- wrap_as_facets_list(facets)

ggproto(NULL, FacetWrap,
shrink = shrink,
params = list(
Expand Down
2 changes: 1 addition & 1 deletion R/fortify-map.r
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fortify.map <- function(model, data, ...) {
#' coord_map("albers", lat0 = 45.5, lat1 = 29.5)
#' }
map_data <- function(map, region = ".", exact = FALSE, ...) {
try_require("maps", "map_data")
check_installed("maps", reason = "for `map_data()`")
map_obj <- maps::map(map, region, exact = exact, plot = FALSE, fill = TRUE, ...)
fortify(map_obj)
}
Expand Down
8 changes: 2 additions & 6 deletions R/fortify.r
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ fortify.data.frame <- function(model, data, ...) model
fortify.tbl_df <- function(model, data, ...) model
#' @export
fortify.tbl <- function(model, data, ...) {
if (!requireNamespace("dplyr", quietly = TRUE)) {
abort("dplyr must be installed to work with tbl objects")
}
check_installed("dplyr", reason = "to work with `tbl` objects")
dplyr::collect(model)
}
#' @export
Expand All @@ -31,9 +29,7 @@ fortify.function <- function(model, data, ...) model
fortify.formula <- function(model, data, ...) as_function(model)
#' @export
fortify.grouped_df <- function(model, data, ...) {
if (!requireNamespace("dplyr", quietly = TRUE)) {
abort("dplyr must be installed to work with grouped_df objects")
}
check_installed("dplyr", reason = "to work with `grouped_df` objects")
model$.group <- dplyr::group_indices(model)
model
}
Expand Down
38 changes: 29 additions & 9 deletions R/geom-contour.r
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#' 2D contours of a 3D surface
#'
#' ggplot2 can not draw true 3D surfaces, but you can use `geom_contour()`,
#' `geom_contour_filled()`, and [geom_tile()] to visualise 3D surfaces in 2D.
#' To specify a valid surface, the data must contain `x`, `y`, and `z` coordinates,
#' and each unique combination of `x` and `y` can appear exactly once. Contouring
#' tends to work best when `x` and `y` form a (roughly) evenly
#' spaced grid. If your data is not evenly spaced, you may want to interpolate
#' to a grid before visualising, see [geom_density_2d()].
#' `geom_contour_filled()`, and [geom_tile()] to visualise 3D surfaces in 2D. To
#' specify a valid surface, the data must contain `x`, `y`, and `z` coordinates,
#' and each unique combination of `x` and `y` can appear at most once.
#' Contouring requires that the points can be rearranged so that the `z` values
#' form a matrix, with rows corresponding to unique `x` values, and columns
#' corresponding to unique `y` values. Missing entries are allowed, but contouring
#' will only be done on cells of the grid with all four `z` values present. If
#' your data is irregular, you can interpolate to a grid before visualising
#' using the [interp::interp()] function from the `interp` package
#' (or one of the interpolating functions from the `akima` package.)
#'
#' @eval rd_aesthetics("geom", "contour")
#' @eval rd_aesthetics("geom", "contour_filled")
Expand All @@ -15,9 +19,9 @@
#' @inheritParams geom_path
#' @param bins Number of contour bins. Overridden by `binwidth`.
#' @param binwidth The width of the contour bins. Overridden by `breaks`.
#' @param breaks Numeric vector to set the contour breaks.
#' Overrides `binwidth` and `bins`. By default, this is a vector of
#' length ten with [pretty()] breaks.
#' @param breaks Numeric vector to set the contour breaks. Overrides `binwidth`
#' and `bins`. By default, this is a vector of length ten with [pretty()]
#' breaks.
#' @seealso [geom_density_2d()]: 2d density contours
#' @export
#' @examples
Expand Down Expand Up @@ -47,6 +51,22 @@
#' v + geom_contour(colour = "red")
#' v + geom_raster(aes(fill = density)) +
#' geom_contour(colour = "white")
#'
#' # Irregular data
#' if (requireNamespace("interp")) {
#' # Use a dataset from the interp package
#' data(franke, package = "interp")
#' origdata <- as.data.frame(interp::franke.data(1, 1, franke))
#' grid <- with(origdata, interp::interp(x, y, z))
#' griddf <- subset(data.frame(x = rep(grid$x, nrow(grid$z)),
#' y = rep(grid$y, each = ncol(grid$z)),
#' z = as.numeric(grid$z)),
#' !is.na(z))
#' ggplot(griddf, aes(x, y, z = z)) +
#' geom_contour_filled() +
#' geom_point(data = origdata)
#' } else
#' message("Irregular data requires the 'interp' package")
#' }
geom_contour <- function(mapping = NULL, data = NULL,
stat = "contour", position = "identity",
Expand Down
Loading