Skip to content

Commit 20ce959

Browse files
committed
Merge branch 'main' into Yunuuuu-multiple_inside_legend_box
2 parents e84a4a4 + 73b4119 commit 20ce959

File tree

92 files changed

+1858
-617
lines changed

Some content is hidden

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

92 files changed

+1858
-617
lines changed

DESCRIPTION

Lines changed: 1 addition & 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'

NAMESPACE

Lines changed: 6 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)
@@ -721,6 +726,7 @@ export(theme_minimal)
721726
export(theme_replace)
722727
export(theme_set)
723728
export(theme_test)
729+
export(theme_transparent)
724730
export(theme_update)
725731
export(theme_void)
726732
export(transform_position)

NEWS.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@
44
"legend.position.inside" and "legend.justification.inside", allowing inside
55
legends to be placed at different positions. Only inside legends with the same
66
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.
723
* In non-orthogonal coordinate systems (`coord_sf()`, `coord_polar()` and
824
`coord_radial()`), using 'AsIs' variables escape transformation when
925
both `x` and `y` is an 'AsIs' variable (@teunbrand, #6205).
@@ -215,7 +231,18 @@
215231
`labs()` and several guides (@teunbrand, #3196).
216232
* `stat_summary_bin()` no longer ignores `width` parameter (@teunbrand, #4647).
217233
* Added `keep.zeroes` argument to `stat_bin()` (@teunbrand, #3449)
234+
* (internal) removed barriers for using 2D structures as aesthetics
235+
(@teunbrand, #4189).
218236
* `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).
219246

220247
# ggplot2 3.5.1
221248

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
}

0 commit comments

Comments
 (0)