Skip to content

Commit f0404ea

Browse files
authored
Merge branch 'main' into date-error-msg
2 parents fdcbdb3 + 1800a9a commit f0404ea

File tree

281 files changed

+6274
-2341
lines changed

Some content is hidden

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

281 files changed

+6274
-2341
lines changed

DESCRIPTION

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Imports:
4444
vctrs (>= 0.6.0),
4545
withr (>= 2.5.0)
4646
Suggests:
47+
broom,
4748
covr,
4849
dplyr,
4950
ggplot2movies,
@@ -126,15 +127,15 @@ Collate:
126127
'facet-grid-.R'
127128
'facet-null.R'
128129
'facet-wrap.R'
129-
'fortify-lm.R'
130130
'fortify-map.R'
131-
'fortify-multcomp.R'
131+
'fortify-models.R'
132132
'fortify-spatial.R'
133133
'fortify.R'
134134
'stat-.R'
135135
'geom-abline.R'
136136
'geom-rect.R'
137137
'geom-bar.R'
138+
'geom-tile.R'
138139
'geom-bin2d.R'
139140
'geom-blank.R'
140141
'geom-boxplot.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'
@@ -242,6 +242,7 @@ Collate:
242242
'scales-.R'
243243
'stat-align.R'
244244
'stat-bin.R'
245+
'stat-summary-2d.R'
245246
'stat-bin2d.R'
246247
'stat-bindot.R'
247248
'stat-binhex.R'
@@ -254,6 +255,7 @@ Collate:
254255
'stat-ellipse.R'
255256
'stat-function.R'
256257
'stat-identity.R'
258+
'stat-manual.R'
257259
'stat-qq-line.R'
258260
'stat-qq.R'
259261
'stat-quantilemethods.R'
@@ -262,7 +264,6 @@ Collate:
262264
'stat-smooth-methods.R'
263265
'stat-smooth.R'
264266
'stat-sum.R'
265-
'stat-summary-2d.R'
266267
'stat-summary-bin.R'
267268
'stat-summary-hex.R'
268269
'stat-summary.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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ S3method(c,mapped_discrete)
2020
S3method(drawDetails,zeroGrob)
2121
S3method(element_grob,element_blank)
2222
S3method(element_grob,element_line)
23+
S3method(element_grob,element_point)
24+
S3method(element_grob,element_polygon)
2325
S3method(element_grob,element_rect)
2426
S3method(element_grob,element_text)
2527
S3method(format,ggproto)
@@ -94,6 +96,7 @@ S3method(makeContext,dotstackGrob)
9496
S3method(merge_element,default)
9597
S3method(merge_element,element)
9698
S3method(merge_element,element_blank)
99+
S3method(merge_element,margin)
97100
S3method(pattern_alpha,GridPattern)
98101
S3method(pattern_alpha,GridTilingPattern)
99102
S3method(pattern_alpha,default)
@@ -172,6 +175,7 @@ export(GeomAbline)
172175
export(GeomAnnotationMap)
173176
export(GeomArea)
174177
export(GeomBar)
178+
export(GeomBin2d)
175179
export(GeomBlank)
176180
export(GeomBoxplot)
177181
export(GeomCol)
@@ -263,6 +267,7 @@ export(StatEcdf)
263267
export(StatEllipse)
264268
export(StatFunction)
265269
export(StatIdentity)
270+
export(StatManual)
266271
export(StatQq)
267272
export(StatQqLine)
268273
export(StatQuantile)
@@ -343,6 +348,8 @@ export(element_blank)
343348
export(element_geom)
344349
export(element_grob)
345350
export(element_line)
351+
export(element_point)
352+
export(element_polygon)
346353
export(element_rect)
347354
export(element_render)
348355
export(element_text)
@@ -475,6 +482,7 @@ export(is.scale)
475482
export(is.stat)
476483
export(is.theme)
477484
export(is.theme_element)
485+
export(is.waiver)
478486
export(label_both)
479487
export(label_bquote)
480488
export(label_context)
@@ -492,6 +500,8 @@ export(layer_sf)
492500
export(lims)
493501
export(map_data)
494502
export(margin)
503+
export(margin_auto)
504+
export(margin_part)
495505
export(max_height)
496506
export(max_width)
497507
export(mean_cl_boot)
@@ -686,6 +696,7 @@ export(stat_ecdf)
686696
export(stat_ellipse)
687697
export(stat_function)
688698
export(stat_identity)
699+
export(stat_manual)
689700
export(stat_qq)
690701
export(stat_qq_line)
691702
export(stat_quantile)
@@ -718,7 +729,19 @@ export(theme_linedraw)
718729
export(theme_minimal)
719730
export(theme_replace)
720731
export(theme_set)
732+
export(theme_sub_axis)
733+
export(theme_sub_axis_bottom)
734+
export(theme_sub_axis_left)
735+
export(theme_sub_axis_right)
736+
export(theme_sub_axis_top)
737+
export(theme_sub_axis_x)
738+
export(theme_sub_axis_y)
739+
export(theme_sub_legend)
740+
export(theme_sub_panel)
741+
export(theme_sub_plot)
742+
export(theme_sub_strip)
721743
export(theme_test)
744+
export(theme_transparent)
722745
export(theme_update)
723746
export(theme_void)
724747
export(transform_position)

NEWS.md

Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,79 @@
22

33
* Date scales silently coerce <POSIXct> to <Date> and datetime scales silently
44
coerce <Date> to <POSIXct> (@laurabrianna, #3533)
5+
* New parameters for `geom_label()` (@teunbrand and @steveharoz, #5365):
6+
* The `linewidth` aesthetic is now applied and replaces the `label.size`
7+
argument.
8+
* The `linetype` aesthetic is now applied.
9+
* New `border.colour` argument to set the colour of borders.
10+
* New `text.colour` argument to set the colour of text.
11+
* New `element_point()` and `element_polygon()` that can be given to
12+
`theme(point, polygon)` as an extension point (@teunbrand, #6248).
13+
* Turned off fallback for `size` to `linewidth` translation in
14+
`geom_bar()`/`geom_col()` (#4848).
15+
* `coord_radial()` now displays no axis instead of throwing an error when
16+
a scale has no breaks (@teunbrand, #6271).
17+
* The `fatten` argument has been deprecated in `geom_boxplot()`,
18+
`geom_crossbar()` and `geom_pointrange()` (@teunbrand, #4881).
19+
* Axis labels are now preserved better when using `coord_sf(expand = TRUE)` and
20+
graticule lines are straight but do not meet the edge (@teunbrand, #2985).
21+
* Attempt to boost detail in `coord_polar()` and `coord_radial()` near the
22+
center (@teunbrand, #5023)
23+
* Scale names, guide titles and aesthetic labels can now accept functions
24+
(@teunbrand, #4313)
25+
* Binned scales with zero-width data expand the default limits by 0.1
26+
(@teunbrand, #5066)
27+
* New default `geom_qq_line(geom = "abline")` for better clipping in the
28+
vertical direction. In addition, `slope` and `intercept` are new computed
29+
variables in `stat_qq_line()` (@teunbrand, #6087).
30+
* Position adjustments can now have auxiliary aesthetics (@teunbrand).
31+
* `position_nudge()` gains `nudge_x` and `nudge_y` aesthetics (#3026, #5445).
32+
* `position_dodge()` gains `order` aesthetic (#3022, #3345)
33+
* More stability for vctrs-based palettes (@teunbrand, #6117).
34+
* Fixed regression in `guide_bins(reverse = TRUE)` (@teunbrand, #6183).
35+
* New function family for setting parts of a theme. For example, you can now use
36+
`theme_sub_axis(line, text, ticks, ticks.length, line)` as a substitute for
37+
`theme(axis.line, axis.text, axis.ticks, axis.ticks.length, axis.line)`. This
38+
should allow slightly terser and more organised theme declarations
39+
(@teunbrand, #5301).
40+
* `scale_{x/y}_discrete(continuous.limits)` is a new argument to control the
41+
display range of discrete scales (@teunbrand, #4174, #6259).
42+
* `geom_ribbon()` now appropriately warns about, and removes, missing values
43+
(@teunbrand, #6243).
44+
* `guide_*()` can now accept two inside legend theme elements:
45+
`legend.position.inside` and `legend.justification.inside`, allowing inside
46+
legends to be placed at different positions. Only inside legends with the same
47+
position and justification will be merged (@Yunuuuu, #6210).
48+
* New stat: `stat_manual()` for arbitrary computations (@teunbrand, #3501)
49+
* Reversal of a dimension, typically 'x' or 'y', is now controlled by the
50+
`reverse` argument in `coord_cartesian()`, `coord_fixed()`, `coord_radial()`
51+
and `coord_sf()`. In `coord_radial()`, this replaces the older `direction`
52+
argument (#4021, @teunbrand).
53+
* `coord_radial()` displays minor gridlines now (@teunbrand).
54+
* (internal) `continuous_scale()` and `binned_scale()` sort the `limits`
55+
argument internally (@teunbrand).
56+
* Theme margins can have NA-units to inherit from parent elements. The new
57+
function `margin_part()` has NA-units as default (@teunbrand, #6115)
58+
* New `margin_auto()` specification for theme margins.
59+
* New argument `labs(dictionary)` to label based on variable name rather than
60+
based on aesthetic (@teunbrand, #5178)
61+
* Fixed bug in out-of-bounds binned breaks (@teunbrand, #6054)
62+
* Binned guides now accept expressions as labels (@teunbrand, #6005)
63+
* (internal) `Scale$get_labels()` format expressions as lists.
64+
* In non-orthogonal coordinate systems (`coord_sf()`, `coord_polar()` and
65+
`coord_radial()`), using 'AsIs' variables escape transformation when
66+
both `x` and `y` is an 'AsIs' variable (@teunbrand, #6205).
67+
* The following methods have been deprecated: `fortify.lm()`, `fortify.glht()`,
68+
`fortify.confint.glht()`, `fortify.summary.glht()` and `fortify.cld()`. It
69+
is recommend to use `broom::augment()` and `broom::tidy()` instead
70+
(@teunbrand, #3816).
71+
* Custom and raster annotation now respond to scale transformations, and can
72+
use AsIs variables for relative placement (@teunbrand based on
73+
@yutannihilation's prior work, #3120)
74+
* When discrete breaks have names, they'll be used as labels by default
75+
(@teunbrand, #6147).
76+
* The helper function `is.waiver()` is now exported to help extensions to work
77+
with `waiver()` objects (@arcresu, #6173).
578
* Date(time) scales now throw appropriate errors when `date_breaks`,
679
`date_minor_breaks` or `date_labels` are not strings (@RodDalBen, #5880)
780
* `geom_errorbarh()` is deprecated in favour of
@@ -10,6 +83,13 @@
1083
(@teunbrand, #4320)
1184
* `geom_boxplot()` gains additional arguments to style the colour, linetype and
1285
linewidths of the box, whiskers, median line and staples (@teunbrand, #5126)
86+
* `geom_violin()` gains additional arguments to style the colour, linetype and
87+
linewidths of the quantiles, which replace the now-deprecated `draw_quantiles`
88+
argument (#5912).
89+
* (breaking) `geom_violin(quantiles)` now has actual quantiles based on
90+
the data, rather than inferred quantiles based on the computed density. The
91+
`quantiles` parameter that replaces `draw_quantiles` now belongs to
92+
`stat_ydensity()` instead of `geom_violin()` (@teunbrand, #4120).
1393
* (internal) Using `after_scale()` in the `Geom*$default_aes()` field is now
1494
evaluated in the context of data (@teunbrand, #6135)
1595
* Fixed bug where binned scales wouldn't simultaneously accept transformations
@@ -198,7 +278,38 @@
198278
* The ellipsis argument is now checked in `fortify()`, `get_alt_text()`,
199279
`labs()` and several guides (@teunbrand, #3196).
200280
* `stat_summary_bin()` no longer ignores `width` parameter (@teunbrand, #4647).
201-
* Added `keep.zeroes` argument to `stat_bin()` (@teunbrand, #3449)
281+
* Reintroduced `drop` argument to `stat_bin()` (@teunbrand, #3449)
282+
* (internal) removed barriers for using 2D structures as aesthetics
283+
(@teunbrand, #4189).
284+
* `coord_sf()` no longer errors when dealing with empty graticules (@teunbrand, #6052)
285+
* Added `theme_transparent()` with transparent backgrounds (@topepo).
286+
* New theme elements `palette.{aes}.discrete` and `palette.{aes}.continuous`.
287+
Theme palettes replace palettes in scales where `palette = NULL`, which is
288+
the new default in many scales (@teunbrand, #4696).
289+
* `guide_axis()` no longer reserves space for blank ticks
290+
(@teunbrand, #4722, #6069).
291+
* `geom_abline()` clips to the panel range in the vertical direction too
292+
(@teunbrand, #6086).
293+
* Added `panel.widths` and `panel.heights` to `theme()` (#5338, @teunbrand).
294+
* Standardised the calculation of `width`, which are now implemented as
295+
aesthetics (@teunbrand, #2800).
296+
* Stricter check on `register_theme_elements(element_tree)` (@teunbrand, #6162)
297+
* Added `weight` aesthetic for `stat_ellipse()` (@teunbrand, #5272)
298+
* Fixed a bug where the `guide_custom(order)` wasn't working (@teunbrand, #6195)
299+
* All binning stats now use the `boundary`/`center` parametrisation rather
300+
than `origin`, following in `stat_bin()`'s footsteps (@teunbrand).
301+
* `stat_summary_2d()` and `stat_bin_2d()` now deal with zero-range data
302+
more elegantly (@teunbrand, #6207).
303+
* Munching in `coord_polar()` and `coord_radial()` now adds more detail,
304+
particularly for data-points with a low radius near the center
305+
(@teunbrand, #5023).
306+
* All scales now expose the `aesthetics` parameter (@teunbrand, #5841)
307+
* Staged expressions are handled more gracefully if legends cannot resolve them
308+
(@teunbrand, #6264).
309+
* New `theme(legend.key.justification)` to control the alignment of legend keys
310+
(@teunbrand, #3669).
311+
* Added `scale_{x/y}_time(date_breaks, date_minor_breaks, date_labels)`
312+
(@teunbrand, #4335).
202313

203314
# ggplot2 3.5.1
204315

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/annotation-custom.R

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,12 @@ GeomCustomAnn <- ggproto("GeomCustomAnn", Geom,
7070

7171
draw_panel = function(data, panel_params, coord, grob, xmin, xmax,
7272
ymin, ymax) {
73-
if (!inherits(coord, "CoordCartesian")) {
74-
cli::cli_abort("{.fn annotation_custom} only works with {.fn coord_cartesian}.")
75-
}
76-
corners <- data_frame0(
77-
x = c(xmin, xmax),
78-
y = c(ymin, ymax),
79-
.size = 2
73+
range <- ranges_annotation(
74+
coord, panel_params, xmin, xmax, ymin, ymax,
75+
fun = "annotation_custom"
8076
)
81-
data <- coord$transform(corners, panel_params)
82-
83-
x_rng <- range(data$x, na.rm = TRUE)
84-
y_rng <- range(data$y, na.rm = TRUE)
85-
86-
vp <- viewport(x = mean(x_rng), y = mean(y_rng),
87-
width = diff(x_rng), height = diff(y_rng),
77+
vp <- viewport(x = mean(range$x), y = mean(range$y),
78+
width = diff(range$x), height = diff(range$y),
8879
just = c("center","center"))
8980
editGrob(grob, vp = vp, name = paste(grob$name, annotation_id()))
9081
},
@@ -99,3 +90,21 @@ annotation_id <- local({
9990
i
10091
}
10192
})
93+
94+
ranges_annotation <- function(coord, panel_params, xmin, xmax, ymin, ymax, fun) {
95+
if (!inherits(coord, "CoordCartesian")) {
96+
cli::cli_abort("{.fn {fun}} only works with {.fn coord_cartesian}.")
97+
}
98+
data <- data_frame0(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax)
99+
data <- .ignore_data(data)[[1]]
100+
x <- panel_params$x$scale$transform_df(data)
101+
data[names(x)] <- x
102+
y <- panel_params$y$scale$transform_df(data)
103+
data[names(y)] <- y
104+
data <- .expose_data(data)[[1]]
105+
data <- coord$transform(data, panel_params)
106+
list(
107+
x = range(data$xmin, data$xmax, na.rm = TRUE),
108+
y = range(data$ymin, data$ymax, na.rm = TRUE)
109+
)
110+
}

R/annotation-raster.R

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,13 @@ GeomRasterAnn <- ggproto("GeomRasterAnn", Geom,
7373

7474
draw_panel = function(data, panel_params, coord, raster, xmin, xmax,
7575
ymin, ymax, interpolate = FALSE) {
76-
if (!inherits(coord, "CoordCartesian")) {
77-
cli::cli_abort("{.fn annotation_raster} only works with {.fn coord_cartesian}.")
78-
}
79-
corners <- data_frame0(
80-
x = c(xmin, xmax),
81-
y = c(ymin, ymax),
82-
.size = 2
76+
range <- ranges_annotation(
77+
coord, panel_params, xmin, xmax, ymin, ymax,
78+
fun = "annotation_raster"
79+
)
80+
rasterGrob(raster, range$x[1], range$y[1],
81+
diff(range$x), diff(range$y), default.units = "native",
82+
just = c("left","bottom"), interpolate = interpolate
8383
)
84-
data <- coord$transform(corners, panel_params)
85-
86-
x_rng <- range(data$x, na.rm = TRUE)
87-
y_rng <- range(data$y, na.rm = TRUE)
88-
89-
rasterGrob(raster, x_rng[1], y_rng[1],
90-
diff(x_rng), diff(y_rng), default.units = "native",
91-
just = c("left","bottom"), interpolate = interpolate)
9284
}
9385
)

0 commit comments

Comments
 (0)