Skip to content

Commit d74ee52

Browse files
committed
resolve merge conflict
Merge branch 'main' into internal_naming # Conflicts: # R/geom-crossbar.R # R/geom-errorbarh.R # R/scale-colour.R # R/scale-hue.R # R/utilities-checks.R # tests/testthat/_snaps/facet-.md # tests/testthat/test-ggsave.R
2 parents ee1a2ba + b35cf63 commit d74ee52

File tree

316 files changed

+6059
-3023
lines changed

Some content is hidden

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

316 files changed

+6059
-3023
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
cache-version: 3
6464
extra-packages: >
6565
any::rcmdcheck,
66-
Hmisc=?ignore-before-r=4.1.0,
66+
Hmisc=?ignore-before-r=4.2.0,
6767
quantreg=?ignore-before-r=4.3.0
6868
needs: check
6969

DESCRIPTION

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: ggplot2
2-
Version: 3.5.1.9000
32
Title: Create Elegant Data Visualisations Using the Grammar of Graphics
3+
Version: 3.5.1.9000
44
Authors@R: c(
55
person("Hadley", "Wickham", , "[email protected]", role = "aut",
66
comment = c(ORCID = "0000-0003-4757-117X")),
@@ -30,21 +30,21 @@ License: MIT + file LICENSE
3030
URL: https://ggplot2.tidyverse.org, https://github.com/tidyverse/ggplot2
3131
BugReports: https://github.com/tidyverse/ggplot2/issues
3232
Depends:
33-
R (>= 3.5)
33+
R (>= 4.0)
3434
Imports:
3535
cli,
3636
grDevices,
3737
grid,
3838
gtable (>= 0.1.1),
3939
isoband,
4040
lifecycle (> 1.0.1),
41-
MASS,
4241
rlang (>= 1.1.0),
4342
scales (>= 1.3.0),
4443
stats,
4544
vctrs (>= 0.6.0),
4645
withr (>= 2.5.0)
4746
Suggests:
47+
broom,
4848
covr,
4949
dplyr,
5050
ggplot2movies,
@@ -53,6 +53,7 @@ Suggests:
5353
knitr,
5454
mapproj,
5555
maps,
56+
MASS,
5657
mgcv,
5758
multcomp,
5859
munsell,
@@ -75,6 +76,7 @@ VignetteBuilder:
7576
knitr
7677
Config/Needs/website: ggtext, tidyr, forcats, tidyverse/tidytemplate
7778
Config/testthat/edition: 3
79+
Config/usethis/last-upkeep: 2024-10-24
7880
Encoding: UTF-8
7981
LazyData: true
8082
Roxygen: list(markdown = TRUE)
@@ -125,15 +127,15 @@ Collate:
125127
'facet-grid-.R'
126128
'facet-null.R'
127129
'facet-wrap.R'
128-
'fortify-lm.R'
129130
'fortify-map.R'
130-
'fortify-multcomp.R'
131+
'fortify-models.R'
131132
'fortify-spatial.R'
132133
'fortify.R'
133134
'stat-.R'
134135
'geom-abline.R'
135136
'geom-rect.R'
136137
'geom-bar.R'
138+
'geom-tile.R'
137139
'geom-bin2d.R'
138140
'geom-blank.R'
139141
'geom-boxplot.R'
@@ -150,7 +152,6 @@ Collate:
150152
'geom-density2d.R'
151153
'geom-dotplot.R'
152154
'geom-errorbar.R'
153-
'geom-errorbarh.R'
154155
'geom-freqpoly.R'
155156
'geom-function.R'
156157
'geom-hex.R'
@@ -167,7 +168,6 @@ Collate:
167168
'geom-smooth.R'
168169
'geom-spoke.R'
169170
'geom-text.R'
170-
'geom-tile.R'
171171
'geom-violin.R'
172172
'geom-vline.R'
173173
'ggplot2-package.R'
@@ -254,6 +254,7 @@ Collate:
254254
'stat-ellipse.R'
255255
'stat-function.R'
256256
'stat-identity.R'
257+
'stat-manual.R'
257258
'stat-qq-line.R'
258259
'stat-qq.R'
259260
'stat-quantilemethods.R'

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
Copyright (c) 2020 ggplot2 authors
3+
Copyright (c) 2024 ggplot2 core developer team
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

NAMESPACE

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ S3method(makeContext,dotstackGrob)
9494
S3method(merge_element,default)
9595
S3method(merge_element,element)
9696
S3method(merge_element,element_blank)
97+
S3method(merge_element,margin)
9798
S3method(pattern_alpha,GridPattern)
9899
S3method(pattern_alpha,GridTilingPattern)
99100
S3method(pattern_alpha,default)
@@ -172,6 +173,7 @@ export(GeomAbline)
172173
export(GeomAnnotationMap)
173174
export(GeomArea)
174175
export(GeomBar)
176+
export(GeomBin2d)
175177
export(GeomBlank)
176178
export(GeomBoxplot)
177179
export(GeomCol)
@@ -263,6 +265,7 @@ export(StatEcdf)
263265
export(StatEllipse)
264266
export(StatFunction)
265267
export(StatIdentity)
268+
export(StatManual)
266269
export(StatQq)
267270
export(StatQqLine)
268271
export(StatQuantile)
@@ -461,7 +464,6 @@ export(guides)
461464
export(has_flipped_aes)
462465
export(is.Coord)
463466
export(is.coord)
464-
export(is.element)
465467
export(is.facet)
466468
export(is.geom)
467469
export(is.ggplot)
@@ -475,6 +477,8 @@ export(is.position)
475477
export(is.scale)
476478
export(is.stat)
477479
export(is.theme)
480+
export(is.theme_element)
481+
export(is.waiver)
478482
export(label_both)
479483
export(label_bquote)
480484
export(label_context)
@@ -492,6 +496,8 @@ export(layer_sf)
492496
export(lims)
493497
export(map_data)
494498
export(margin)
499+
export(margin_auto)
500+
export(margin_part)
495501
export(max_height)
496502
export(max_width)
497503
export(mean_cl_boot)
@@ -686,6 +692,7 @@ export(stat_ecdf)
686692
export(stat_ellipse)
687693
export(stat_function)
688694
export(stat_identity)
695+
export(stat_manual)
689696
export(stat_qq)
690697
export(stat_qq_line)
691698
export(stat_quantile)
@@ -719,6 +726,7 @@ export(theme_minimal)
719726
export(theme_replace)
720727
export(theme_set)
721728
export(theme_test)
729+
export(theme_transparent)
722730
export(theme_update)
723731
export(theme_void)
724732
export(transform_position)

NEWS.md

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

3+
* `guide_*()` can now accept two inside legend theme elements:
4+
`legend.position.inside` and `legend.justification.inside`, allowing inside
5+
legends to be placed at different positions. Only inside legends with the same
6+
position and justification will be merged (@Yunuuuu, #6210).
7+
* New stat: `stat_manual()` for arbitrary computations (@teunbrand, #3501)
8+
* Reversal of a dimension, typically 'x' or 'y', is now controlled by the
9+
`reverse` argument in `coord_cartesian()`, `coord_fixed()`, `coord_radial()`
10+
and `coord_sf()`. In `coord_radial()`, this replaces the older `direction`
11+
argument (#4021, @teunbrand).
12+
* `coord_radial()` displays minor gridlines now (@teunbrand).
13+
* (internal) `continuous_scale()` and `binned_scale()` sort the `limits`
14+
argument internally (@teunbrand).
15+
* Theme margins can have NA-units to inherit from parent elements. The new
16+
function `margin_part()` has NA-units as default (@teunbrand, #6115)
17+
* New `margin_auto()` specification for theme margins.
18+
* New argument `labs(dictionary)` to label based on variable name rather than
19+
based on aesthetic (@teunbrand, #5178)
20+
* Fixed bug in out-of-bounds binned breaks (@teunbrand, #6054)
21+
* Binned guides now accept expressions as labels (@teunbrand, #6005)
22+
* (internal) `Scale$get_labels()` format expressions as lists.
23+
* In non-orthogonal coordinate systems (`coord_sf()`, `coord_polar()` and
24+
`coord_radial()`), using 'AsIs' variables escape transformation when
25+
both `x` and `y` is an 'AsIs' variable (@teunbrand, #6205).
26+
* The following methods have been deprecated: `fortify.lm()`, `fortify.glht()`,
27+
`fortify.confint.glht()`, `fortify.summary.glht()` and `fortify.cld()`. It
28+
is recommend to use `broom::augment()` and `broom::tidy()` instead
29+
(@teunbrand, #3816).
30+
* Custom and raster annotation now respond to scale transformations, and can
31+
use AsIs variables for relative placement (@teunbrand based on
32+
@yutannihilation's prior work, #3120)
33+
* When discrete breaks have names, they'll be used as labels by default
34+
(@teunbrand, #6147).
35+
* The helper function `is.waiver()` is now exported to help extensions to work
36+
with `waiver()` objects (@arcresu, #6173).
37+
* Date(time) scales now throw appropriate errors when `date_breaks`,
38+
`date_minor_breaks` or `date_labels` are not strings (@RodDalBen, #5880)
39+
* `geom_errorbarh()` is deprecated in favour of
40+
`geom_errorbar(orientation = "y")` (@teunbrand, #5961).
41+
* `geom_contour()` should be able to recognise a rotated grid of points
42+
(@teunbrand, #4320)
43+
* `geom_boxplot()` gains additional arguments to style the colour, linetype and
44+
linewidths of the box, whiskers, median line and staples (@teunbrand, #5126)
45+
* (internal) Using `after_scale()` in the `Geom*$default_aes()` field is now
46+
evaluated in the context of data (@teunbrand, #6135)
47+
* Fixed bug where binned scales wouldn't simultaneously accept transformations
48+
and function-limits (@teunbrand, #6144).
49+
* Fixed bug where the `ggplot2::`-prefix did not work with `stage()`
50+
(@teunbrand, #6104).
351
* New `get_labs()` function for retrieving completed plot labels
452
(@teunbrand, #6008).
553
* Built-in `theme_*()` functions now have `ink` and `paper` arguments to control
@@ -182,6 +230,19 @@
182230
* The ellipsis argument is now checked in `fortify()`, `get_alt_text()`,
183231
`labs()` and several guides (@teunbrand, #3196).
184232
* `stat_summary_bin()` no longer ignores `width` parameter (@teunbrand, #4647).
233+
* Added `keep.zeroes` argument to `stat_bin()` (@teunbrand, #3449)
234+
* (internal) removed barriers for using 2D structures as aesthetics
235+
(@teunbrand, #4189).
236+
* `coord_sf()` no longer errors when dealing with empty graticules (@teunbrand, #6052)
237+
* Added `theme_transparent()` with transparent backgrounds (@topepo).
238+
* New theme elements `palette.{aes}.discrete` and `palette.{aes}.continuous`.
239+
Theme palettes replace palettes in scales where `palette = NULL`, which is
240+
the new default in many scales (@teunbrand, #4696).
241+
* `guide_axis()` no longer reserves space for blank ticks
242+
(@teunbrand, #4722, #6069).
243+
* `geom_abline()` clips to the panel range in the vertical direction too
244+
(@teunbrand, #6086).
245+
* Added `panel.widths` and `panel.heights` to `theme()` (#5338, @teunbrand).
185246

186247
# ggplot2 3.5.1
187248

@@ -228,6 +289,7 @@ documentation updates.
228289
* `annotate()` now warns about `stat` or `position` arguments (@teunbrand, #5151)
229290
* `guide_coloursteps(even.steps = FALSE)` now works with discrete data that has
230291
been formatted by `cut()` (@teunbrand, #3877).
292+
* `ggsave()` now offers to install svglite if needed (@eliocamp, #6166).
231293

232294
# ggplot2 3.5.0
233295

R/aes-evaluation.R

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#' Below follows an overview of the three stages of evaluation and how aesthetic
3333
#' evaluation can be controlled.
3434
#'
35-
#' ## Stage 1: direct input
35+
#' ## Stage 1: direct input at the start
3636
#' The default is to map at the beginning, using the layer data provided by
3737
#' the user. If you want to map directly from the layer data you should not do
3838
#' anything special. This is the only stage where the original layer data can
@@ -87,17 +87,19 @@
8787
#' ```
8888
#'
8989
#' ## Complex staging
90-
#' If you want to map the same aesthetic multiple times, e.g. map `x` to a
91-
#' data column for the stat, but remap it for the geom, you can use the
92-
#' `stage()` function to collect multiple mappings.
90+
#' Sometimes, you may want to map the same aesthetic multiple times, e.g. map
91+
#' `x` to a data column at the start for the layer stat, but remap it later to
92+
#' a variable from the stat transformation for the layer geom. The `stage()`
93+
#' function allows you to control multiple mappings for the same aesthetic
94+
#' across all three stages of evaluation.
9395
#'
9496
#' ```r
9597
#' # Use stage to modify the scaled fill
9698
#' ggplot(mpg, aes(class, hwy)) +
9799
#' geom_boxplot(aes(fill = stage(class, after_scale = alpha(fill, 0.4))))
98100
#'
99101
#' # Using data for computing summary, but placing label elsewhere.
100-
#' # Also, we're making our own computed variable to use for the label.
102+
#' # Also, we're making our own computed variables to use for the label.
101103
#' ggplot(mpg, aes(class, displ)) +
102104
#' geom_violin() +
103105
#' stat_summary(
@@ -110,6 +112,11 @@
110112
#' )
111113
#' ```
112114
#'
115+
#' Conceptually, `aes(x)` is equivalent to `aes(stage(start = x))`, and
116+
#' `aes(after_stat(count))` is equivalent to `aes(stage(after_stat = count))`,
117+
#' and so on. `stage()` is most useful when at least two of its arguments are
118+
#' specified.
119+
#'
113120
#' ## Theme access
114121
#' The `from_theme()` function can be used to acces the [`element_geom()`]
115122
#' fields of the `theme(geom)` argument. Using `aes(colour = from_theme(ink))`
@@ -332,7 +339,7 @@ strip_stage <- function(expr) {
332339
} else if (is_call(uq_expr, "stage")) {
333340
uq_expr <- call_match(uq_expr, stage)
334341
# Prefer stat mapping if present, otherwise original mapping (fallback to
335-
# scale mapping) but there should always be two arguments to stage()
342+
# scale mapping)
336343
uq_expr$after_stat %||% uq_expr$start %||% uq_expr$after_scale
337344
} else {
338345
expr
@@ -358,3 +365,39 @@ make_labels <- function(mapping) {
358365
}
359366
Map(default_label, names(mapping), mapping)
360367
}
368+
369+
eval_aesthetics <- function(aesthetics, data, mask = NULL) {
370+
371+
env <- child_env(base_env())
372+
373+
# Here we mask functions, often to replace `stage()` with context appropriate
374+
# functions `stage_calculated()`/`stage_scaled()`.
375+
if (length(mask) > 0) {
376+
aesthetics <- substitute_aes(aesthetics, mask_function, mask = mask)
377+
}
378+
379+
evaled <- lapply(aesthetics, eval_tidy, data = data, env = env)
380+
names(evaled) <- names(aesthetics)
381+
compact(rename_aes(evaled))
382+
}
383+
384+
# `mask` is a list of functions where `names(mask)` indicate names of functions
385+
# that need to be replaced, and `mask[[i]]` is the function to replace it
386+
# with.
387+
mask_function <- function(x, mask) {
388+
if (!is.call(x)) {
389+
return(x)
390+
}
391+
nms <- names(mask)
392+
x[-1] <- lapply(x[-1], mask_function, mask = mask)
393+
if (!is_call(x, nms)) {
394+
return(x)
395+
}
396+
for (nm in nms) {
397+
if (is_call(x, nm)) {
398+
x[[1]] <- mask[[nm]]
399+
return(x)
400+
}
401+
}
402+
}
403+

R/aes.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,12 @@ rename_aes <- function(x) {
198198
}
199199
x
200200
}
201-
substitute_aes <- function(x) {
201+
202+
# `x` is assumed to be a strict list of quosures;
203+
# it should have no non-quosure constants in it, even though `aes()` allows it.
204+
substitute_aes <- function(x, fun = standardise_aes_symbols, ...) {
202205
x <- lapply(x, function(aesthetic) {
203-
as_quosure(standardise_aes_symbols(quo_get_expr(aesthetic)), env = environment(aesthetic))
206+
as_quosure(fun(quo_get_expr(aesthetic), ...), env = environment(aesthetic))
204207
})
205208
class(x) <- "uneval"
206209
x

0 commit comments

Comments
 (0)