Skip to content

Commit 66de6bc

Browse files
committed
Merge branch 'main' into test_symmetry
2 parents 75be620 + 8d9f428 commit 66de6bc

File tree

108 files changed

+3050
-3025
lines changed

Some content is hidden

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

108 files changed

+3050
-3025
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: ggplot2
22
Title: Create Elegant Data Visualisations Using the Grammar of Graphics
3-
Version: 4.0.0.9000
3+
Version: 4.0.1.9000
44
Authors@R: c(
55
person("Hadley", "Wickham", , "[email protected]", role = "aut",
66
comment = c(ORCID = "0000-0003-4757-117X")),
@@ -206,6 +206,7 @@ Collate:
206206
'plot-build.R'
207207
'plot-construction.R'
208208
'plot-last.R'
209+
'plot-render.R'
209210
'plot.R'
210211
'position-.R'
211212
'position-collide.R'

NEWS.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
# ggplot2 (development version)
22

3+
* `get_layer_data()` and `get_layer_grob()` now accept layer names as index
4+
(@lgaborini, #6724)
5+
6+
# ggplot2 4.0.1
7+
8+
This is a smaller patch release focussed on fixing regressions from 4.0.0 and
9+
polishing the recent features.
10+
11+
## Bug fixes
12+
313
* Fixed regression where `geom_area()` didn't draw panels with single groups
414
when `stat = "align"` (@teunbrand, #6680)
515
* Fixed regression where `position_stack(vjust)` was ignored when there are
616
only single groups (#6692)
717
* Fixed bug where `NA` handling in `geom_path()` was ignoring panels (@teunbrand, #6533)
8-
* Logical values for the linetype aesthetic will be interpreted numerically,
9-
so that `linetype = FALSE` becomes 0/'blank' and `linetype = TRUE` becomes
10-
1/'solid' (@teunbrand, #6641)
11-
* Out-of-bounds datapoints used as padding by `stat_align()` now get removed
12-
silently rather than verbosely (@teunbrand, #6667)
1318
* Fixed bug where `stat_bin(boundary)` was ignored (#6682).
1419
* `geom_text()` and `geom_label()` accept expressions as the `label` aesthetic
1520
(@teunbrand, #6638)
1621
* Fixed regression where `draw_key_rect()` stopped using `fill` colours
1722
(@mitchelloharawild, #6609).
1823
* Fixed regression where `scale_{x,y}_*()` threw an error when an expression
1924
object is set to `labels` argument (@yutannihilation, #6617).
20-
* Improved palette fallback mechanism in scales (@teunbrand, #6669).
21-
* Allow `stat` in `geom_hline`, `geom_vline`, and `geom_abline`. (@sierrajohnson, #6559)
22-
* `stat_boxplot()` treats `width` as an optional aesthetic (@Yunuuuu, #6575)
2325
* Fixed regression where the first (unnamed) argument to colour/fill scales was
2426
not passed as the `name` argument (@teunbrand, #6623)
2527
* Fixed issue where vectorised `arrow()`s caused errors in drawing the
@@ -28,10 +30,21 @@
2830
insistently. Now they contribute only as fallback labels (@teunbrand, #6616)
2931
* Fixed regression where empty arguments to colour/fill scale caused errors
3032
(@jmbarbone, #6710)
33+
* Fixed axis misplacement in `coor_radial()` when labels are blank (@teunbrand, #6574)
34+
35+
## Improvements
36+
37+
* Improved palette fallback mechanism in scales (@teunbrand, #6669).
38+
* Allow `stat` in `geom_hline`, `geom_vline`, and `geom_abline`. (@sierrajohnson, #6559)
39+
* `stat_boxplot()` treats `width` as an optional aesthetic (@Yunuuuu, #6575)
3140
* The `theme(panel.widths, panel.heights)` setting attempts to preserve the
3241
plot's aspect ratio when only one of the two settings is given, and the plot
3342
has a single panel (@teunbrand, #6701).
34-
* Fixed axis misplacement in `coor_radial()` when labels are blank (@teunbrand, #6574)
43+
* Logical values for the linetype aesthetic will be interpreted numerically,
44+
so that `linetype = FALSE` becomes 0/'blank' and `linetype = TRUE` becomes
45+
1/'solid' (@teunbrand, #6641)
46+
* Out-of-bounds datapoints used as padding by `stat_align()` now get removed
47+
silently rather than verbosely (@teunbrand, #6667)
3548

3649
# ggplot2 4.0.0
3750

R/annotate.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
#' @param geom name of geom to use for annotation
1919
#' @param x,y,xmin,ymin,xmax,ymax,xend,yend positioning aesthetics -
2020
#' you must specify at least one of these.
21-
#' @inheritParams layer
22-
#' @inheritParams geom_point
21+
#' @inheritParams shared_layer_parameters
2322
#' @seealso
2423
#' The `r link_book("custom annotations section", "annotations#sec-custom-annotations")`
2524
#' @export

R/docs-layer.R

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,146 @@
1+
# Shared parameters -------------------------------------------------------
2+
3+
#' @name shared_layer_parameters
4+
#' @title Shared layer parameters
5+
#' @description
6+
#' This is a central place for describing typical layer parameters.
7+
#' It prevents cluttered definitions all over the place.
8+
#'
9+
#' @param mapping
10+
#' Set of aesthetic mappings created by [aes()]. If specified and `inherit.aes =
11+
#' TRUE` (the default), it is combined with the default mapping at the top level
12+
#' of the plot. You must supply `mapping` if there is no plot mapping.
13+
#'
14+
#' @param data
15+
#' The data to be displayed in this layer. There are three options:
16+
#' * `NULL` (default): the data is inherited from the plot data as specified
17+
#' in the call to [ggplot()].
18+
#' * A `data.frame`, or other object, will override the plot data. All objects
19+
#' will be fortified to produce a data frame. See [fortify()] for which
20+
#' variables will be created.
21+
#' * A `function` will be called with a single argument, the plot data. The return
22+
#' value must be a `data.frame`, and will be used as the layer data. A
23+
#' `function` can be created from a `formula` (e.g. `~ head(.x, 10)`).
24+
#'
25+
#' @param geom
26+
#' The geometric object to use to display the data for this layer. When using a
27+
#' `stat_*()` function to construct a layer, the `geom` argument can be used to
28+
#' override the default coupling between stats and geoms. The `geom` argument
29+
#' accepts the following:
30+
#' * A `Geom` ggproto subclass, for example `GeomPoint`.
31+
#' * A string naming the geom. To give the geom as a string, strip the
32+
#' function name of the `geom_` prefix. For example, to use `geom_point()`,
33+
#' give the geom as `"point"`.
34+
#' * For more information and other ways to specify the geom, see the
35+
#' [layer geom][layer_geoms] documentation.
36+
#'
37+
#' @param stat
38+
#' The statistical transformation to use on the data for this layer. When using
39+
#' a `geom_*()` function to construct a layer, the `stat` argument can be used
40+
#' to override the default coupling between geoms and stats. The `stat` argument
41+
#' accepts the following:
42+
#' * A `Stat` ggproto subclass, for example `StatCount`.
43+
#' * A string naming the stat. To give the stat as a string, strip the
44+
#' function name of the `stat_` prefix. For example, to use `stat_count()`,
45+
#' give the stat as `"count"`.
46+
#' * For more information and other ways to specify the stat, see the
47+
#' [layer stat][layer_stats] documentation.
48+
#'
49+
#' @param position
50+
#' A position adjustment to use on the data for this layer. This can be used in
51+
#' various ways, including to prevent overplotting and improving the display.
52+
#' The `position` argument accepts the following:
53+
#' * The result of calling a position function, such as `position_jitter()`.
54+
#' This method allows for passing extra arguments to the position.
55+
#' * A string naming the position adjustment. To give the position as a
56+
#' string, strip the function name of the `position_` prefix. For example, to
57+
#' use `position_jitter()`, give the position as `"jitter"`.
58+
#' * For more information and other ways to specify the position, see the
59+
#' [layer position][layer_positions] documentation.
60+
#'
61+
#' @param na.rm
62+
#' If `FALSE`, the default, missing values are removed with a warning. If
63+
#' `TRUE`, missing values are silently removed.
64+
#'
65+
#' @param show.legend
66+
#' Logical. Should this layer be included in the legends? `NA`, the default,
67+
#' includes if any aesthetics are mapped. `FALSE` never includes, and `TRUE`
68+
#' always includes. It can also be a named logical vector to finely select the
69+
#' aesthetics to display. To include legend keys for all levels, even when no
70+
#' data exists, use `TRUE`. If `NA`, all levels are shown in legend, but
71+
#' unobserved levels are omitted.
72+
#'
73+
#' @param inherit.aes
74+
#' If `FALSE`, overrides the default aesthetics, rather than combining with
75+
#' them. This is most useful for helper functions that define both data and
76+
#' aesthetics and shouldn't inherit behaviour from the default plot
77+
#' specification, e.g. [annotation_borders()].
78+
#'
79+
#' @param ...
80+
#' Other arguments passed on to [layer()]'s `params` argument. These arguments
81+
#' broadly fall into one of 4 categories below. Notably, further arguments to
82+
#' the `position` argument, or aesthetics that are required can
83+
#' *not* be passed through `...`. Unknown arguments that are not part of the 4
84+
#' categories below are ignored.
85+
#' * Static aesthetics that are not mapped to a scale, but are at a fixed
86+
#' value and apply to the layer as a whole. For example, `colour = "red"` or
87+
#' `linewidth = 3`. The geom's documentation has an **Aesthetics** section
88+
#' that lists the available options. The 'required' aesthetics cannot be
89+
#' passed on to the `params`. Please note that while passing unmapped
90+
#' aesthetics as vectors is technically possible, the order and required
91+
#' length is not guaranteed to be parallel to the input data.
92+
#' * When constructing a layer using
93+
#' a `stat_*()` function, the `...` argument can be used to pass on parameters
94+
#' to the `geom` part of the layer. An example of this is
95+
#' `stat_density(geom = "area", outline.type = "both")`. The geom's
96+
#' documentation lists which parameters it can accept.
97+
#' * Inversely, when constructing a layer using a
98+
#' `geom_*()` function, the `...` argument can be used to pass on parameters
99+
#' to the `stat` part of the layer. An example of this is
100+
#' `geom_area(stat = "density", adjust = 0.5)`. The stat's documentation lists
101+
#' which parameters it can accept.
102+
#' * The `key_glyph` argument of [`layer()`] may also be passed on through
103+
#' `...`. This can be one of the functions described as
104+
#' [key glyphs][draw_key], to change the display of the layer in the legend.
105+
#'
106+
#' @param lineend
107+
#' Line end style, one of `"round"`, `"butt"` or `"square"`.
108+
#'
109+
#' @param linejoin
110+
#' Line join style, one of `"round"`, `"mitre"` or `"bevel"`.
111+
#'
112+
#' @param linemitre
113+
#' Line mitre limit, a number greater than 1.
114+
#'
115+
#' @param arrow
116+
#' Arrow specification. Can be created by [grid::arrow()] or `NULL` to not draw
117+
#' an arrow.
118+
#'
119+
#' @param arrow.fill
120+
#' Fill colour to use for closed arrowheads. `NULL` means use `colour`
121+
#' aesthetic.
122+
#'
123+
#' @param orientation
124+
#' The orientation of the layer. The default (`NA`) automatically determines the
125+
#' orientation from the aesthetic mapping. In the rare event that this fails it
126+
#' can be given explicitly by setting `orientation` to either `"x"` or `"y"`.
127+
#' See the *Orientation* section for more detail.
128+
#'
129+
#' @section Orientation:
130+
#' This geom treats each axis differently and, thus, can have two
131+
#' orientations. Often the orientation is easy to deduce from a combination of
132+
#' the given mappings and the types of positional scales in use. Thus, ggplot2
133+
#' will by default try to guess which orientation the layer should have. Under
134+
#' rare circumstances, the orientation is ambiguous and guessing may fail. In
135+
#' that case the orientation can be specified directly using the `orientation`
136+
#' parameter, which can be either `"x"` or `"y"`. The value gives the axis that
137+
#' the geom should run along, `"x"` being the default orientation you would
138+
#' expect for the geom.
139+
#'
140+
#' @keywords internal
141+
#' @aliases NULL
142+
NULL
143+
1144
# Geoms -------------------------------------------------------------------
2145

3146
#' @title

R/facet-wrap.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ NULL
4040
#' `"all_x"` and `"all_y"` will draw the respective axes at the interior
4141
#' panels too, whereas `"all"` will draw all axes at all panels.
4242
#' @param axis.labels Determines whether to draw labels for interior axes when
43-
#' the scale is fixed and the `axis` argument is not `"margins"`. When
43+
#' the scale is fixed and the `axes` argument is not `"margins"`. When
4444
#' `"all"` (default), all interior axes get labels. When `"margins"`, only
4545
#' the exterior axes get labels, and the interior axes get none. When
4646
#' `"all_x"` or `"all_y"`, only draws the labels at the interior axes in the

R/geom-abline-hline-vline.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ NULL
3131
#'
3232
#' @seealso See [geom_segment()] for a more general approach to
3333
#' adding straight line segments to a plot.
34-
#' @inheritParams layer
35-
#' @inheritParams geom_point
34+
#' @inheritParams shared_layer_parameters
3635
#' @param mapping Set of aesthetic mappings created by [aes()].
3736
#' @param xintercept,yintercept,slope,intercept Parameters that control the
3837
#' position of the line. If these are set, `data`, `mapping` and

R/geom-bar.R

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ GeomCol <- ggproto("GeomCol", GeomBar)
7474
#' [position_fill()] shows relative proportions at each `x` by stacking the
7575
#' bars and then standardising each bar to have the same height.
7676
#'
77-
#' @eval rd_orientation()
77+
#' @inheritSection shared_layer_parameters Orientation
7878
#'
7979
#' @aesthetics GeomBar
8080
#' @aesthetics GeomCol
@@ -84,12 +84,7 @@ GeomCol <- ggproto("GeomCol", GeomBar)
8484
#' [position_dodge()] and [position_dodge2()] for creating side-by-side
8585
#' bar charts.
8686
#' @export
87-
#' @inheritParams layer
88-
#' @inheritParams geom_point
89-
#' @param orientation The orientation of the layer. The default (`NA`)
90-
#' automatically determines the orientation from the aesthetic mapping. In the
91-
#' rare event that this fails it can be given explicitly by setting `orientation`
92-
#' to either `"x"` or `"y"`. See the *Orientation* section for more detail.
87+
#' @inheritParams shared_layer_parameters
9388
#' @param just Adjustment for column placement. Set to `0.5` by default, meaning
9489
#' that columns will be centered about axis breaks. Set to `0` or `1` to place
9590
#' columns to the left/right of axis breaks. Note that this argument may have
@@ -98,8 +93,6 @@ GeomCol <- ggproto("GeomCol", GeomBar)
9893
#' @param geom,stat Override the default connection between `geom_bar()` and
9994
#' `stat_count()`. For more information about overriding these connections,
10095
#' see how the [stat][layer_stats] and [geom][layer_geoms] arguments work.
101-
#' @param lineend Line end style (round, butt, square).
102-
#' @param linejoin Line join style (round, mitre, bevel).
10396
#' @examples
10497
#' # geom_bar is designed to make it easy to create bar charts that show
10598
#' # counts (or sums of weights)

R/geom-bin2d.R

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@ GeomBin2d <- ggproto("GeomBin2d", GeomTile)
1717
#' @aesthetics GeomBin2d
1818
#'
1919
#' @export
20-
#' @inheritParams layer
21-
#' @inheritParams geom_point
20+
#' @inheritParams shared_layer_parameters
2221
#' @param geom,stat Use to override the default connection between
2322
#' `geom_bin_2d()` and `stat_bin_2d()`. For more information about overriding
2423
#' these connections, see how the [stat][layer_stats] and [geom][layer_geoms]
2524
#' arguments work.
26-
#' @param lineend Line end style (round, butt, square).
27-
#' @param linejoin Line join style (round, mitre, bevel).
2825
#' @seealso [stat_bin_hex()] for hexagonal binning
2926
#' @examples
3027
#' d <- ggplot(diamonds, aes(x, y)) + xlim(4, 10) + ylim(4, 10)

R/geom-blank.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
#' more details.
66
#'
77
#' @export
8-
#' @inheritParams layer
9-
#' @inheritParams geom_point
8+
#' @inheritParams shared_layer_parameters
109
#' @examples
1110
#' ggplot(mtcars, aes(wt, mpg))
1211
#' # Nothing to see here!

R/geom-boxplot.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' It visualises five summary statistics (the median, two hinges
55
#' and two whiskers), and all "outlying" points individually.
66
#'
7-
#' @eval rd_orientation()
7+
#' @inheritSection shared_layer_parameters Orientation
88
#'
99
#' @section Summary statistics:
1010
#' The lower and upper hinges correspond to the first and third quartiles
@@ -29,8 +29,7 @@
2929
#' @seealso [geom_quantile()] for continuous `x`,
3030
#' [geom_violin()] for a richer display of the distribution, and
3131
#' [geom_jitter()] for a useful technique for small data.
32-
#' @inheritParams layer
33-
#' @inheritParams geom_bar
32+
#' @inheritParams shared_layer_parameters
3433
#' @param geom,stat Use to override the default connection between
3534
#' `geom_boxplot()` and `stat_boxplot()`. For more information about
3635
#' overriding these connections, see how the [stat][layer_stats] and

0 commit comments

Comments
 (0)