Skip to content

Commit fa2bd6b

Browse files
authored
Merge branch 'main' into sanitise_bins
2 parents d15151f + 321b300 commit fa2bd6b

File tree

113 files changed

+1662
-614
lines changed

Some content is hidden

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

113 files changed

+1662
-614
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ Collate:
274274
'theme.R'
275275
'theme-defaults.R'
276276
'theme-current.R'
277+
'theme-sub.R'
277278
'utilities-break.R'
278279
'utilities-grid.R'
279280
'utilities-help.R'

NAMESPACE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,17 @@ export(theme_linedraw)
725725
export(theme_minimal)
726726
export(theme_replace)
727727
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)
728739
export(theme_test)
729740
export(theme_transparent)
730741
export(theme_update)

NEWS.md

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

3-
* All binning stats now use the `boundary`/`center` parametrisation rather
4-
than `origin`, following in `stat_bin()`'s footsteps (@teunbrand).
5-
* `stat_summary_2d()` and `stat_bin_2d()` now deal with zero-range data
6-
more elegantly (@teunbrand, #6207).
3+
* New default `geom_qq_line(geom = "abline")` for better clipping in the
4+
vertical direction. In addition, `slope` and `intercept` are new computed
5+
variables in `stat_qq_line()` (@teunbrand, #6087).
6+
* Position adjustments can now have auxiliary aesthetics (@teunbrand).
7+
* `position_nudge()` gains `nudge_x` and `nudge_y` aesthetics (#3026, #5445).
8+
* `position_dodge()` gains `order` aesthetic (#3022, #3345)
9+
* More stability for vctrs-based palettes (@teunbrand, #6117).
10+
* Fixed regression in `guide_bins(reverse = TRUE)` (@teunbrand, #6183).
11+
* New function family for setting parts of a theme. For example, you can now use
12+
`theme_sub_axis(line, text, ticks, ticks.length, line)` as a substitute for
13+
`theme(axis.line, axis.text, axis.ticks, axis.ticks.length, axis.line)`. This
14+
should allow slightly terser and more organised theme declarations
15+
(@teunbrand, #5301).
16+
* `scale_{x/y}_discrete(continuous.limits)` is a new argument to control the
17+
display range of discrete scales (@teunbrand, #4174, #6259).
718
* `geom_ribbon()` now appropriately warns about, and removes, missing values
819
(@teunbrand, #6243).
920
* `guide_*()` can now accept two inside legend theme elements:
@@ -48,6 +59,13 @@
4859
(@teunbrand, #4320)
4960
* `geom_boxplot()` gains additional arguments to style the colour, linetype and
5061
linewidths of the box, whiskers, median line and staples (@teunbrand, #5126)
62+
* `geom_violin()` gains additional arguments to style the colour, linetype and
63+
linewidths of the quantiles, which replace the now-deprecated `draw_quantiles`
64+
argument (#5912).
65+
* (breaking) `geom_violin(quantiles)` now has actual quantiles based on
66+
the data, rather than inferred quantiles based on the computed density. The
67+
`quantiles` parameter that replaces `draw_quantiles` now belongs to
68+
`stat_ydensity()` instead of `geom_violin()` (@teunbrand, #4120).
5169
* (internal) Using `after_scale()` in the `Geom*$default_aes()` field is now
5270
evaluated in the context of data (@teunbrand, #6135)
5371
* Fixed bug where binned scales wouldn't simultaneously accept transformations
@@ -249,6 +267,15 @@
249267
* `geom_abline()` clips to the panel range in the vertical direction too
250268
(@teunbrand, #6086).
251269
* Added `panel.widths` and `panel.heights` to `theme()` (#5338, @teunbrand).
270+
* Standardised the calculation of `width`, which are now implemented as
271+
aesthetics (@teunbrand, #2800).
272+
* Stricter check on `register_theme_elements(element_tree)` (@teunbrand, #6162)
273+
* Added `weight` aesthetic for `stat_ellipse()` (@teunbrand, #5272)
274+
* Fixed a bug where the `guide_custom(order)` wasn't working (@teunbrand, #6195)
275+
* All binning stats now use the `boundary`/`center` parametrisation rather
276+
than `origin`, following in `stat_bin()`'s footsteps (@teunbrand).
277+
* `stat_summary_2d()` and `stat_bin_2d()` now deal with zero-range data
278+
more elegantly (@teunbrand, #6207).
252279

253280
# ggplot2 3.5.1
254281

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-radial.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' @param end Position from 12 o'clock in radians where plot ends, to allow
55
#' for partial polar coordinates. The default, `NULL`, is set to
66
#' `start + 2 * pi`.
7-
#' @param expand If `TRUE`, the default, adds a small expansion factor the
7+
#' @param expand If `TRUE`, the default, adds a small expansion factor to
88
#' the limits to prevent overlap between data and axes. If `FALSE`, limits
99
#' are taken directly from the scale.
1010
#' @param r.axis.inside One of the following:
@@ -191,7 +191,7 @@ CoordRadial <- ggproto("CoordRadial", Coord,
191191
# Validate appropriateness of guides
192192
drop_guides <- character(0)
193193
for (type in aesthetics) {
194-
drop_guides <- check_polar_guide(drop_guides, guides, type)
194+
drop_guides <- validate_polar_guide(drop_guides, guides, type)
195195
}
196196

197197
guide_params <- guides$get_params(aesthetics)
@@ -603,7 +603,7 @@ theta_grid <- function(theta, element, inner_radius = c(0, 0.4),
603603
)
604604
}
605605

606-
check_polar_guide <- function(drop_list, guides, type = "theta") {
606+
validate_polar_guide <- function(drop_list, guides, type = "theta") {
607607
guide <- guides$get_guide(type)
608608
primary <- gsub("\\.sec$", "", type)
609609
if (inherits(guide, "GuideNone") || primary %in% guide$available_aes) {

R/facet-.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ df.grid <- function(a, b) {
443443
# facetting variables.
444444

445445
as_facets_list <- function(x) {
446-
x <- validate_facets(x)
446+
check_vars(x)
447447
if (is_quosures(x)) {
448448
x <- quos_auto_name(x)
449449
return(list(x))
@@ -487,7 +487,7 @@ as_facets_list <- function(x) {
487487
x
488488
}
489489

490-
validate_facets <- function(x) {
490+
check_vars <- function(x) {
491491
if (is.mapping(x)) {
492492
cli::cli_abort("Please use {.fn vars} to supply facet variables.")
493493
}
@@ -499,7 +499,7 @@ validate_facets <- function(x) {
499499
"i" = "Did you use {.code %>%} or {.code |>} instead of {.code +}?"
500500
))
501501
}
502-
x
502+
invisible()
503503
}
504504

505505
# Flatten a list of quosures objects to a quosures object, and compact it

R/facet-grid-.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ facet_grid <- function(rows = NULL, cols = NULL, scales = "fixed",
177177
facets_list <- grid_as_facets_list(rows, cols)
178178

179179
# Check for deprecated labellers
180-
labeller <- check_labeller(labeller)
180+
labeller <- fix_labeller(labeller)
181181

182182
ggproto(NULL, FacetGrid,
183183
shrink = shrink,

R/facet-wrap.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ facet_wrap <- function(facets, nrow = NULL, ncol = NULL, scales = "fixed",
174174
)
175175

176176
# Check for deprecated labellers
177-
labeller <- check_labeller(labeller)
177+
labeller <- fix_labeller(labeller)
178178

179179
# Flatten all facets dimensions into a single one
180180
facets <- compact_facets(facets)

R/fortify.R

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,34 +44,46 @@ fortify.grouped_df <- function(model, data, ...) {
4444
# There are a lot of ways that dim(), colnames(), or as.data.frame() could
4545
# do non-sensical things (they are not even guaranteed to work!) hence the
4646
# paranoid mode.
47-
.prevalidate_data_frame_like_object <- function(data) {
47+
check_data_frame_like <- function(data) {
4848
orig_dims <- dim(data)
49-
if (!vec_is(orig_dims, integer(), size=2))
50-
cli::cli_abort(paste0("{.code dim(data)} must return ",
51-
"an {.cls integer} of length 2."))
52-
if (anyNA(orig_dims) || any(orig_dims < 0)) # extra-paranoid mode
53-
cli::cli_abort(paste0("{.code dim(data)} can't have {.code NA}s ",
54-
"or negative values."))
49+
if (!vec_is(orig_dims, integer(), size = 2)) {
50+
cli::cli_abort(
51+
"{.code dim(data)} must return an {.cls integer} of length 2."
52+
)
53+
}
54+
if (anyNA(orig_dims) || any(orig_dims < 0)) { # extra-paranoid mode
55+
cli::cli_abort(
56+
"{.code dim(data)} can't have {.code NA}s or negative values."
57+
)
58+
}
5559
orig_colnames <- colnames(data)
56-
if (!vec_is(orig_colnames, character(), size = ncol(data)))
57-
cli::cli_abort(paste0("{.code colnames(data)} must return a ",
58-
"{.cls character} of length {.code ncol(data)}."))
60+
if (!vec_is(orig_colnames, character(), size = ncol(data))) {
61+
cli::cli_abort(
62+
"{.code colnames(data)} must return a {.cls character} of length {.code ncol(data)}."
63+
)
64+
}
65+
invisible()
5966
}
60-
.postvalidate_data_frame_like_object <- function(df, data) {
67+
check_data_frame_conversion <- function(new, old) {
6168
msg0 <- "{.code as.data.frame(data)} must "
62-
if (!is.data.frame(df))
69+
if (!is.data.frame(new)) {
6370
cli::cli_abort(paste0(msg0, "return a {.cls data.frame}."))
64-
if (!identical(dim(df), dim(data)))
71+
}
72+
if (!identical(dim(new), dim(old))) {
6573
cli::cli_abort(paste0(msg0, "preserve dimensions."))
66-
if (!identical(colnames(df), colnames(data)))
74+
}
75+
if (!identical(colnames(new), colnames(old))) {
6776
cli::cli_abort(paste0(msg0, "preserve column names."))
77+
}
78+
invisible()
6879
}
6980
validate_as_data_frame <- function(data) {
70-
if (is.data.frame(data))
81+
if (is.data.frame(data)) {
7182
return(data)
72-
.prevalidate_data_frame_like_object(data)
83+
}
84+
check_data_frame_like(data)
7385
df <- as.data.frame(data)
74-
.postvalidate_data_frame_like_object(df, data)
86+
check_data_frame_conversion(df, data)
7587
df
7688
}
7789

R/geom-.R

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,11 @@ Geom <- ggproto("Geom",
170170
)
171171

172172
# Check that all output are valid data
173-
nondata_modified <- check_nondata_cols(modified_aes)
174-
if (length(nondata_modified) > 0) {
175-
issues <- paste0("{.code ", nondata_modified, " = ", as_label(modifiers[[nondata_modified]]), "}")
176-
names(issues) <- rep("x", length(issues))
177-
cli::cli_abort(c(
178-
"Aesthetic modifiers returned invalid values",
179-
"x" = "The following mappings are invalid",
180-
issues,
181-
"i" = "Did you map the modifier in the wrong layer?"
182-
))
183-
}
173+
check_nondata_cols(
174+
modified_aes, modifiers,
175+
problem = "Aesthetic modifiers returned invalid values.",
176+
hint = "Did you map the modifier in the wrong layer?"
177+
)
184178

185179
modified_aes <- cleanup_mismatched_data(modified_aes, nrow(data), "after_scale")
186180

@@ -283,7 +277,7 @@ check_aesthetics <- function(x, n) {
283277
))
284278
}
285279

286-
check_linewidth <- function(data, name) {
280+
fix_linewidth <- function(data, name) {
287281
if (is.null(data$linewidth) && !is.null(data$size)) {
288282
deprecate_soft0("3.4.0", I(paste0("Using the `size` aesthetic with ", name)), I("the `linewidth` aesthetic"))
289283
data$linewidth <- data$size

0 commit comments

Comments
 (0)