Skip to content

Commit 8f27d7a

Browse files
authored
Merge branch 'master' into v3.2.1-rc
2 parents ee20fe8 + 541ae99 commit 8f27d7a

File tree

136 files changed

+5402
-1870
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+5402
-1870
lines changed

.travis.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
language: R
22
cache: packages
3-
sudo: true
4-
dist: trusty
53

64
# build matrix; turn on vdiffr only on r release
75
matrix:
@@ -35,8 +33,13 @@ env:
3533
after_success:
3634
- Rscript -e 'covr::codecov()'
3735

38-
before_install:
39-
- sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable --yes
40-
- sudo apt-get --yes --force-yes update -qq
41-
- sudo apt-get install --yes libudunits2-dev libproj-dev libgeos-dev libgdal-dev
42-
- Rscript -e 'update.packages(ask = FALSE)'
36+
addons:
37+
apt:
38+
sources:
39+
- sourceline: 'ppa:ubuntugis/ppa'
40+
packages:
41+
- libudunits2-dev
42+
- libproj-dev
43+
- libgeos-dev
44+
- libgdal-dev
45+

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ quickly as possible. The guide is divided into two main pieces:
66
1. Filing a bug report or feature request in an issue.
77
1. Suggesting a change via a pull request.
88

9-
Please note that ggplot2 is released with a [Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md). By contributing to this project,
9+
Please note that ggplot2 is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this project,
1010
you agree to abide by its terms.
1111

1212
## Issues

DESCRIPTION

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Suggests:
3939
ggplot2movies,
4040
hexbin,
4141
Hmisc,
42+
isoband,
4243
knitr,
4344
lattice,
4445
mapproj,
@@ -54,7 +55,7 @@ Suggests:
5455
rpart,
5556
sf (>= 0.7-3),
5657
svglite (>= 1.2.0.9001),
57-
testthat (>= 0.11.0),
58+
testthat (>= 2.1.0),
5859
vdiffr (>= 0.3.0)
5960
Enhances: sp
6061
License: GPL-2 | file LICENSE
@@ -190,6 +191,7 @@ Collate:
190191
'scale-continuous.r'
191192
'scale-date.r'
192193
'scale-discrete-.r'
194+
'scale-expansion.r'
193195
'scale-gradient.r'
194196
'scale-grey.r'
195197
'scale-hue.r'
@@ -199,6 +201,7 @@ Collate:
199201
'scale-shape.r'
200202
'scale-size.r'
201203
'scale-type.R'
204+
'scale-view.r'
202205
'scale-viridis.r'
203206
'scales-.r'
204207
'stat-bin.r'

NAMESPACE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ S3method(ggplot_add,Coord)
4949
S3method(ggplot_add,Facet)
5050
S3method(ggplot_add,Layer)
5151
S3method(ggplot_add,Scale)
52+
S3method(ggplot_add,by)
5253
S3method(ggplot_add,data.frame)
5354
S3method(ggplot_add,default)
5455
S3method(ggplot_add,guides)
@@ -204,6 +205,7 @@ export(StatBindot)
204205
export(StatBinhex)
205206
export(StatBoxplot)
206207
export(StatContour)
208+
export(StatContourFilled)
207209
export(StatCount)
208210
export(StatDensity)
209211
export(StatDensity2d)
@@ -290,6 +292,7 @@ export(ensym)
290292
export(ensyms)
291293
export(expand_limits)
292294
export(expand_scale)
295+
export(expansion)
293296
export(expr)
294297
export(facet_grid)
295298
export(facet_null)
@@ -304,6 +307,7 @@ export(geom_blank)
304307
export(geom_boxplot)
305308
export(geom_col)
306309
export(geom_contour)
310+
export(geom_contour_filled)
307311
export(geom_count)
308312
export(geom_crossbar)
309313
export(geom_curve)
@@ -518,6 +522,7 @@ export(stat_bin_hex)
518522
export(stat_binhex)
519523
export(stat_boxplot)
520524
export(stat_contour)
525+
export(stat_contour_filled)
521526
export(stat_count)
522527
export(stat_density)
523528
export(stat_density2d)

NEWS.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,60 @@
11
# ggplot2 (development version)
22

3+
* stacking text when calculating the labels and the y axis with
4+
`stat_summary()` now works (@ikosmidis, #2709)
5+
6+
* Allowed reversing of discrete scales by re-writing `get_limits()` (@AnneLyng, #3115)
7+
8+
* Added `stat_contour_filled()` and `geom_contour_filled()`, which compute
9+
and draw filled contours of gridded data (@paleolimbot, #3044).
10+
11+
* `geom_contour()` and `stat_contour()` now use the isoband package
12+
to compute contour lines. The `complete` parameter (which was undocumented
13+
and has been unused for at least four years) was removed (@paleolimbot, #3044).
14+
15+
* `stat_smooth()` user `REML` by default, if `method = "gam"` and
16+
`gam`'s method is not specified (@ikosmidis, #2630).
17+
18+
* Changed `theme_grey()` setting for legend key so that it creates no
19+
border (`NA`) rather than drawing a white one. (@annennenne, #3180)
20+
21+
* Added function `ggplot_add.by()` for lists created with `by()` (#2734, @Maschette)
22+
23+
* `ggdep()` was deprecated (@perezp44, #3382).
24+
25+
* Added weight aesthetic option to `stat_density()` and made scaling of
26+
weights the default (@annennenne, #2902)
27+
28+
* `expand_scale()` was deprecated in favour of `expansion()` for setting
29+
the `expand` argument of `x` and `y` scales (@paleolimbot).
30+
31+
* `coord_trans()` now draws second axes and accepts `xlim`, `ylim`,
32+
and `expand` arguments to bring it up to feature parity with
33+
`coord_cartesian()`. The `xtrans` and `ytrans` arguments that were
34+
deprecated in version 1.0.1 in favour of `x` and `y`
35+
were removed (@paleolimbot, #2990).
36+
37+
* `coord_trans()` now calculates breaks using the expanded range
38+
(previously these were calculated using the unexpanded range,
39+
which resulted in differences between plots made with `coord_trans()`
40+
and those made with `coord_cartesian()`). The expansion for discrete axes
41+
in `coord_trans()` was also updated such that it behaves identically
42+
to that in `coord_cartesian()` (@paleolimbot, #3338).
43+
44+
* All `coord_*()` functions with `xlim` and `ylim` arguments now accept
45+
vectors with `NA` as a placeholder for the minimum or maximum value
46+
(e.g., `ylim = c(0, NA)` would zoom the y-axis from 0 to the
47+
maximum value observed in the data). This mimics the behaviour
48+
of the `limits` argument in continuous scale functions
49+
(@paleolimbot, #2907).
50+
51+
* `geom_abline()`, `geom_hline()`, and `geom_vline()` now issue
52+
more informative warnings when supplied with set aesthetics
53+
(i.e., `slope`, `intercept`, `yintercept`, and/or `xintercept`)
54+
and mapped aesthetics (i.e., `data` and/or `mapping`).
55+
56+
* `stat_density2d()` can now take an `adjust` parameter to scale the default bandwidth. (#2860, @haleyjeppson)
57+
358
# ggplot2 3.2.1
459

560
This is a patch release fixing a few regressions introduced in 3.2.0 as well as

R/aes.r

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ NULL
88
#' [ggplot2()] and in individual layers.
99
#'
1010
#' This function also standardises aesthetic names by converting `color` to `colour`
11-
#' (also in substrings, e.g. `point_color` to `point_colour`) and translating old style
12-
#' R names to ggplot names (eg. `pch` to `shape`, `cex` to `size`).
11+
#' (also in substrings, e.g., `point_color` to `point_colour`) and translating old style
12+
#' R names to ggplot names (e.g., `pch` to `shape` and `cex` to `size`).
1313
#'
1414
#' @section Quasiquotation:
1515
#'
@@ -22,9 +22,13 @@ NULL
2222
#' programming vignette](http://dplyr.tidyverse.org/articles/programming.html)
2323
#' to learn more about these techniques.
2424
#'
25-
#' @param x,y,... List of name value pairs giving aesthetics to map to
26-
#' variables. The names for x and y aesthetics are typically omitted because
27-
#' they are so common; all other aesthetics must be named.
25+
#' @param x,y,... List of name-value pairs in the form `aesthetic = variable`
26+
#' describing which variables in the layer data should be mapped to which
27+
#' aesthetics used by the paired geom/stat. The expression `variable` is
28+
#' evaluated within the layer data, so there is no need to refer to
29+
#' the original dataset (i.e., use `ggplot(df, aes(variable))`
30+
#' instead of `ggplot(df, aes(df$variable))`). The names for x and y aesthetics
31+
#' are typically omitted because they are so common; all other aesthetics must be named.
2832
#' @seealso [vars()] for another quoting function designed for
2933
#' faceting specifications.
3034
#' @return A list with class `uneval`. Components of the list are either
@@ -334,3 +338,55 @@ mapped_aesthetics <- function(x) {
334338
is_null <- vapply(x, is.null, logical(1))
335339
names(x)[!is_null]
336340
}
341+
342+
343+
#' Check a mapping for discouraged usage
344+
#'
345+
#' Checks that `$` and `[[` are not used when the target *is* the data
346+
#'
347+
#' @param mapping A mapping created with [aes()]
348+
#' @param data The data to be mapped from
349+
#'
350+
#' @noRd
351+
warn_for_aes_extract_usage <- function(mapping, data) {
352+
lapply(mapping, function(quosure) {
353+
warn_for_aes_extract_usage_expr(get_expr(quosure), data, get_env(quosure))
354+
})
355+
}
356+
357+
warn_for_aes_extract_usage_expr <- function(x, data, env = emptyenv()) {
358+
if (is_call(x, "[[") || is_call(x, "$")) {
359+
if (extract_target_is_likely_data(x, data, env)) {
360+
good_usage <- alternative_aes_extract_usage(x)
361+
warning(
362+
"Use of `", format(x), "` is discouraged. ",
363+
"Use `", good_usage, "` instead.",
364+
call. = FALSE
365+
)
366+
}
367+
} else if (is.call(x)) {
368+
lapply(x, warn_for_aes_extract_usage_expr, data, env)
369+
}
370+
}
371+
372+
alternative_aes_extract_usage <- function(x) {
373+
if (is_call(x, "[[")) {
374+
good_call <- call2("[[", quote(.data), x[[3]])
375+
format(good_call)
376+
} else if (is_call(x, "$")) {
377+
as.character(x[[3]])
378+
} else {
379+
stop("Don't know how to get alternative usage for `", format(x), "`", call. = FALSE)
380+
}
381+
}
382+
383+
extract_target_is_likely_data <- function(x, data, env) {
384+
if (!is.name(x[[2]])) {
385+
return(FALSE)
386+
}
387+
388+
tryCatch({
389+
data_eval <- eval_tidy(x[[2]], data, env)
390+
identical(data_eval, data)
391+
}, error = function(err) FALSE)
392+
}

R/axis-secondary.R

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,49 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,
187187

188188
# patch for date and datetime scales just to maintain functionality
189189
# works only for linear secondary transforms that respect the time or date transform
190-
if (scale$trans$name %in% c("date", "time")){
190+
if (scale$trans$name %in% c("date", "time")) {
191191
temp_scale <- self$create_scale(new_range, trans = scale$trans)
192192
range_info <- temp_scale$break_info()
193-
names(range_info) <- paste0("sec.", names(range_info))
194-
return(range_info)
195-
}
193+
old_val_trans <- rescale(range_info$major, from = c(0, 1), to = range)
194+
old_val_minor_trans <- rescale(range_info$minor, from = c(0, 1), to = range)
195+
} else {
196+
temp_scale <- self$create_scale(new_range)
197+
range_info <- temp_scale$break_info()
196198

197-
temp_scale <- self$create_scale(new_range)
198-
range_info <- temp_scale$break_info()
199+
# Map the break values back to their correct position on the primary scale
200+
old_val <- lapply(range_info$major_source, function(x) which.min(abs(full_range - x)))
201+
old_val <- old_range[unlist(old_val)]
202+
old_val_trans <- scale$trans$transform(old_val)
203+
204+
old_val_minor <- lapply(range_info$minor_source, function(x) which.min(abs(full_range - x)))
205+
old_val_minor <- old_range[unlist(old_val_minor)]
206+
old_val_minor_trans <- scale$trans$transform(old_val_minor)
207+
208+
# rescale values from 0 to 1
209+
range_info$major[] <- round(
210+
rescale(
211+
scale$map(old_val_trans, range(old_val_trans)),
212+
from = range
213+
),
214+
digits = 3
215+
)
216+
217+
range_info$minor[] <- round(
218+
rescale(
219+
scale$map(old_val_minor_trans, range(old_val_minor_trans)),
220+
from = range
221+
),
222+
digits = 3
223+
)
224+
}
199225

200-
# Map the break values back to their correct position on the primary scale
201-
old_val <- lapply(range_info$major_source, function(x) which.min(abs(full_range - x)))
202-
old_val <- old_range[unlist(old_val)]
203-
old_val_trans <- scale$trans$transform(old_val)
204-
range_info$major[] <- round(rescale(scale$map(old_val_trans, range(old_val_trans)), from = range), digits = 3)
226+
# The _source values should be in (primary) scale_transformed space,
227+
# so that the coord doesn't have to know about the secondary scale transformation
228+
# when drawing the axis. The values in user space are useful for testing.
229+
range_info$major_source_user <- range_info$major_source
230+
range_info$minor_source_user <- range_info$minor_source
231+
range_info$major_source[] <- old_val_trans
232+
range_info$minor_source[] <- old_val_minor_trans
205233

206234
names(range_info) <- paste0("sec.", names(range_info))
207235
range_info

R/bin.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ bin_breaks_bins <- function(x_range, bins = 30, center = NULL,
102102
if (bins < 1) {
103103
stop("Need at least one bin.", call. = FALSE)
104104
} else if (zero_range(x_range)) {
105-
# 0.1 is the same width as the expansion `expand_default()` gives for 0-width data
105+
# 0.1 is the same width as the expansion `default_expansion()` gives for 0-width data
106106
width <- 0.1
107107
} else if (bins == 1) {
108108
width <- diff(x_range)

0 commit comments

Comments
 (0)