Skip to content

Commit 0705333

Browse files
committed
fix merge conflict
Merge branch 'main' into attr_stability # Conflicts: # R/layer.R
2 parents d67286a + aa6ee95 commit 0705333

File tree

165 files changed

+2998
-1016
lines changed

Some content is hidden

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

165 files changed

+2998
-1016
lines changed

DESCRIPTION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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'
@@ -273,6 +274,7 @@ Collate:
273274
'theme.R'
274275
'theme-defaults.R'
275276
'theme-current.R'
277+
'theme-sub.R'
276278
'utilities-break.R'
277279
'utilities-grid.R'
278280
'utilities-help.R'

NAMESPACE

Lines changed: 16 additions & 0 deletions
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)
@@ -264,6 +265,7 @@ export(StatEcdf)
264265
export(StatEllipse)
265266
export(StatFunction)
266267
export(StatIdentity)
268+
export(StatManual)
267269
export(StatQq)
268270
export(StatQqLine)
269271
export(StatQuantile)
@@ -494,6 +496,8 @@ export(layer_sf)
494496
export(lims)
495497
export(map_data)
496498
export(margin)
499+
export(margin_auto)
500+
export(margin_part)
497501
export(max_height)
498502
export(max_width)
499503
export(mean_cl_boot)
@@ -688,6 +692,7 @@ export(stat_ecdf)
688692
export(stat_ellipse)
689693
export(stat_function)
690694
export(stat_identity)
695+
export(stat_manual)
691696
export(stat_qq)
692697
export(stat_qq_line)
693698
export(stat_quantile)
@@ -720,6 +725,17 @@ export(theme_linedraw)
720725
export(theme_minimal)
721726
export(theme_replace)
722727
export(theme_set)
728+
export(theme_sub_axis)
729+
export(theme_sub_axis_bottom)
730+
export(theme_sub_axis_left)
731+
export(theme_sub_axis_right)
732+
export(theme_sub_axis_top)
733+
export(theme_sub_axis_x)
734+
export(theme_sub_axis_y)
735+
export(theme_sub_legend)
736+
export(theme_sub_panel)
737+
export(theme_sub_plot)
738+
export(theme_sub_strip)
723739
export(theme_test)
724740
export(theme_transparent)
725741
export(theme_update)

NEWS.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,35 @@
22

33
* (internal) layer data can be attenuated with parameter attributes
44
(@teunbrand, #3175).
5+
* Position adjustments can now have auxiliary aesthetics (@teunbrand).
6+
* `position_nudge()` gains `nudge_x` and `nudge_y` aesthetics (#3026, #5445).
7+
* `position_dodge()` gains `order` aesthetic (#3022, #3345)
8+
* More stability for vctrs-based palettes (@teunbrand, #6117).
9+
* Fixed regression in `guide_bins(reverse = TRUE)` (@teunbrand, #6183).
10+
* New function family for setting parts of a theme. For example, you can now use
11+
`theme_sub_axis(line, text, ticks, ticks.length, line)` as a substitute for
12+
`theme(axis.line, axis.text, axis.ticks, axis.ticks.length, axis.line)`. This
13+
should allow slightly terser and more organised theme declarations
14+
(@teunbrand, #5301).
15+
* `scale_{x/y}_discrete(continuous.limits)` is a new argument to control the
16+
display range of discrete scales (@teunbrand, #4174, #6259).
17+
* `geom_ribbon()` now appropriately warns about, and removes, missing values
18+
(@teunbrand, #6243).
19+
* `guide_*()` can now accept two inside legend theme elements:
20+
`legend.position.inside` and `legend.justification.inside`, allowing inside
21+
legends to be placed at different positions. Only inside legends with the same
22+
position and justification will be merged (@Yunuuuu, #6210).
23+
* New stat: `stat_manual()` for arbitrary computations (@teunbrand, #3501)
24+
* Reversal of a dimension, typically 'x' or 'y', is now controlled by the
25+
`reverse` argument in `coord_cartesian()`, `coord_fixed()`, `coord_radial()`
26+
and `coord_sf()`. In `coord_radial()`, this replaces the older `direction`
27+
argument (#4021, @teunbrand).
28+
* `coord_radial()` displays minor gridlines now (@teunbrand).
29+
* (internal) `continuous_scale()` and `binned_scale()` sort the `limits`
30+
argument internally (@teunbrand).
31+
* Theme margins can have NA-units to inherit from parent elements. The new
32+
function `margin_part()` has NA-units as default (@teunbrand, #6115)
33+
* New `margin_auto()` specification for theme margins.
534
* New argument `labs(dictionary)` to label based on variable name rather than
635
based on aesthetic (@teunbrand, #5178)
736
* Fixed bug in out-of-bounds binned breaks (@teunbrand, #6054)
@@ -29,6 +58,13 @@
2958
(@teunbrand, #4320)
3059
* `geom_boxplot()` gains additional arguments to style the colour, linetype and
3160
linewidths of the box, whiskers, median line and staples (@teunbrand, #5126)
61+
* `geom_violin()` gains additional arguments to style the colour, linetype and
62+
linewidths of the quantiles, which replace the now-deprecated `draw_quantiles`
63+
argument (#5912).
64+
* (breaking) `geom_violin(quantiles)` now has actual quantiles based on
65+
the data, rather than inferred quantiles based on the computed density. The
66+
`quantiles` parameter that replaces `draw_quantiles` now belongs to
67+
`stat_ydensity()` instead of `geom_violin()` (@teunbrand, #4120).
3268
* (internal) Using `after_scale()` in the `Geom*$default_aes()` field is now
3369
evaluated in the context of data (@teunbrand, #6135)
3470
* Fixed bug where binned scales wouldn't simultaneously accept transformations
@@ -218,13 +254,22 @@
218254
`labs()` and several guides (@teunbrand, #3196).
219255
* `stat_summary_bin()` no longer ignores `width` parameter (@teunbrand, #4647).
220256
* Added `keep.zeroes` argument to `stat_bin()` (@teunbrand, #3449)
257+
* (internal) removed barriers for using 2D structures as aesthetics
258+
(@teunbrand, #4189).
221259
* `coord_sf()` no longer errors when dealing with empty graticules (@teunbrand, #6052)
222260
* Added `theme_transparent()` with transparent backgrounds (@topepo).
223261
* New theme elements `palette.{aes}.discrete` and `palette.{aes}.continuous`.
224262
Theme palettes replace palettes in scales where `palette = NULL`, which is
225263
the new default in many scales (@teunbrand, #4696).
226264
* `guide_axis()` no longer reserves space for blank ticks
227265
(@teunbrand, #4722, #6069).
266+
* `geom_abline()` clips to the panel range in the vertical direction too
267+
(@teunbrand, #6086).
268+
* Added `panel.widths` and `panel.heights` to `theme()` (#5338, @teunbrand).
269+
* Standardised the calculation of `width`, which are now implemented as
270+
aesthetics (@teunbrand, #2800).
271+
* Stricter check on `register_theme_elements(element_tree)` (@teunbrand, #6162)
272+
* Added `weight` aesthetic for `stat_ellipse()` (@teunbrand, #5272)
228273

229274
# ggplot2 3.5.1
230275

R/aes.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ NULL
3838
#'
3939
#' [Delayed evaluation][aes_eval] for working with computed variables.
4040
#'
41+
#' @note
42+
#' Using `I()` to create objects of class 'AsIs' causes scales to ignore the
43+
#' variable and assumes the wrapped variable is direct input for the grid
44+
#' package. Please be aware that variables are sometimes combined, like in
45+
#' some stats or position adjustments, that may yield unexpected results with
46+
#' 'AsIs' variables.
47+
#'
4148
#' @family aesthetics documentation
4249
#' @return A list with class `uneval`. Components of the list are either
4350
#' quosures or constants.

R/coord-.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Coord <- ggproto("Coord",
5959
# "on" = yes, "off" = no
6060
clip = "on",
6161

62+
# Should any of the scales be reversed?
63+
reverse = "none",
64+
6265
aspect = function(ranges) NULL,
6366

6467
labels = function(self, labels, panel_params) {
@@ -185,11 +188,7 @@ Coord <- ggproto("Coord",
185188
is_free = function() FALSE,
186189

187190
setup_params = function(self, data) {
188-
list(
189-
guide_default = guide_axis(),
190-
guide_missing = guide_none(),
191-
expand = parse_coord_expand(self$expand %||% TRUE)
192-
)
191+
list(expand = parse_coord_expand(self$expand %||% TRUE))
193192
},
194193

195194
setup_data = function(data, params = list()) {

R/coord-cartesian-.R

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#' limits are set via `xlim` and `ylim` and some data points fall outside those
2626
#' limits, then those data points may show up in places such as the axes, the
2727
#' legend, the plot title, or the plot margins.
28+
#' @param reverse A string giving which directions to reverse. `"none"`
29+
#' (default) keeps directions as is. `"x"` and `"y"` can be used to reverse
30+
#' their respective directions. `"xy"` can be used to reverse both
31+
#' directions.
2832
#' @export
2933
#' @examples
3034
#' # There are two ways of zooming the plot display: with scales or
@@ -64,11 +68,12 @@
6468
#' # displayed bigger
6569
#' d + coord_cartesian(xlim = c(0, 1))
6670
coord_cartesian <- function(xlim = NULL, ylim = NULL, expand = TRUE,
67-
default = FALSE, clip = "on") {
71+
default = FALSE, clip = "on", reverse = "none") {
6872
check_coord_limits(xlim)
6973
check_coord_limits(ylim)
7074
ggproto(NULL, CoordCartesian,
7175
limits = list(x = xlim, y = ylim),
76+
reverse = reverse,
7277
expand = expand,
7378
default = default,
7479
clip = clip
@@ -97,8 +102,11 @@ CoordCartesian <- ggproto("CoordCartesian", Coord,
97102
self$range(panel_params)
98103
},
99104

100-
transform = function(data, panel_params) {
101-
data <- transform_position(data, panel_params$x$rescale, panel_params$y$rescale)
105+
transform = function(self, data, panel_params) {
106+
reverse <- self$reverse %||% "none"
107+
x <- panel_params$x[[switch(reverse, xy = , x = "reverse", "rescale")]]
108+
y <- panel_params$y[[switch(reverse, xy = , y = "reverse", "rescale")]]
109+
data <- transform_position(data, x, y)
102110
transform_position(data, squish_infinite, squish_infinite)
103111
},
104112

@@ -109,14 +117,8 @@ CoordCartesian <- ggproto("CoordCartesian", Coord,
109117
)
110118
},
111119

112-
render_bg = function(panel_params, theme) {
113-
guide_grid(
114-
theme,
115-
panel_params$x$break_positions_minor(),
116-
panel_params$x$break_positions(),
117-
panel_params$y$break_positions_minor(),
118-
panel_params$y$break_positions()
119-
)
120+
render_bg = function(self, panel_params, theme) {
121+
guide_grid(theme, panel_params, self)
120122
},
121123

122124
render_axis_h = function(panel_params, theme) {

R/coord-fixed.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222
#' p + coord_fixed(xlim = c(15, 30))
2323
#'
2424
#' # Resize the plot to see that the specified aspect ratio is maintained
25-
coord_fixed <- function(ratio = 1, xlim = NULL, ylim = NULL, expand = TRUE, clip = "on") {
25+
coord_fixed <- function(ratio = 1, xlim = NULL, ylim = NULL, expand = TRUE,
26+
clip = "on", reverse = "none") {
2627
check_coord_limits(xlim)
2728
check_coord_limits(ylim)
2829
ggproto(NULL, CoordFixed,
2930
limits = list(x = xlim, y = ylim),
3031
ratio = ratio,
3132
expand = expand,
33+
reverse = reverse,
3234
clip = clip
3335
)
3436
}

R/coord-polar.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#' # to demonstrate how these common plots can be described in the
2121
#' # grammar. Use with EXTREME caution.
2222
#'
23-
#' #' # A pie chart = stacked bar chart + polar coordinates
23+
#' # A pie chart = stacked bar chart + polar coordinates
2424
#' pie <- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) +
2525
#' geom_bar(width = 1)
2626
#' pie + coord_polar(theta = "y")

0 commit comments

Comments
 (0)