Skip to content

Polishes triggered by revdep failures #6506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c4ffa57
don't extract <element_blank>@hjust
teunbrand Jun 13, 2025
6c13d47
ensure `if` switch is scalar
teunbrand Jun 13, 2025
16c3084
contingency where `merge_element(..., e2 = <S3_element>)`
teunbrand Jun 16, 2025
bad1e32
cast a wider net for function matching
teunbrand Jun 16, 2025
593f326
Fix NOTE: no visible binding for global variable 'properties'
teunbrand Jun 16, 2025
e169794
stabilise missingness detection for 2D structures
teunbrand Jun 16, 2025
7a886b8
avoid recursion issue when `theme` is missing
teunbrand Jun 17, 2025
a15f1ac
avoid renaming argument for S3 method consistency purposes
teunbrand Jun 17, 2025
6743479
demote warning to message
teunbrand Jun 18, 2025
ec193c0
stop complaints about 0-length labels, which is commonly used in labe…
teunbrand Jun 18, 2025
2429d31
allow merging <S3> + <S3>
teunbrand Jun 18, 2025
27465ff
fix #6521
teunbrand Jun 19, 2025
5cb124c
fix #6513
teunbrand Jun 19, 2025
afb019e
avoid rare error when using GeomSf based extensions
teunbrand Jun 19, 2025
b82fc4a
`label.size` should be soft-deprecated first
teunbrand Jun 20, 2025
29e08d3
Merge branch 'main' into revdep_deprecated_theme
teunbrand Jun 23, 2025
e7e08d5
put `convert` into `local()` too
teunbrand Jun 23, 2025
3655a59
restore accent colour for `geom_contour()`
teunbrand Jun 23, 2025
3ab6b3a
new revdepcheck
thomasp85 Jun 23, 2025
fd63768
Merge branch 'revdep_deprecated_theme' of https://github.com/teunbran…
teunbrand Jun 23, 2025
2b22612
don't prepend `""` as class
teunbrand Jun 24, 2025
db292e6
mark the binning change as a breaking change
teunbrand Jun 26, 2025
78e6aec
fix #6531
teunbrand Jun 26, 2025
d3d2956
fix #6529
teunbrand Jun 26, 2025
7547832
no longer soft-deprecated
teunbrand Jun 26, 2025
1436853
attempt to tone down spurious warnings
teunbrand Jun 27, 2025
93df56a
fallback for translating `geom_errorbarh(height)`
teunbrand Jun 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
rather than in the layer method of `update_ggplot()`
(previously `ggplot_add.Layer()`). This may affect code that accessed the
`plot$labels` property (@teunbrand, #5894).
* In binning stats, the default `boundary` is now chosen to better adhere to
the `nbin` argument. This may affect plots that use default binning
(@teunbrand, #5882, #5036)

### Lifecycle changes

Expand Down Expand Up @@ -218,8 +221,6 @@
aesthetics (@teunbrand, #2800, #3142, #5740, #3722).
* All binning stats now use the `boundary`/`center` parametrisation rather
than `origin`, following in `stat_bin()`'s footsteps (@teunbrand).
* In `stat_bin()`, the default `boundary` is now chosen to better adhere to
the `nbin` argument (@teunbrand, #5882, #5036)
* Reintroduced `drop` argument to `stat_bin()` (@teunbrand, #3449)
* `stat_bin()` now accepts functions for argument `breaks` (@aijordan, #4561)
* `after_stat()` and `after_scale()` throw warnings when the computed aesthetics
Expand Down
2 changes: 1 addition & 1 deletion R/aes.R
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ is_position_aes <- function(vars) {
#'
#' @section Life cycle:
#'
#' All these functions are soft-deprecated. Please use tidy evaluation idioms
#' All these functions are deprecated. Please use tidy evaluation idioms
#' instead. Regarding `aes_string()`, you can replace it with `.data` pronoun.
#' For example, the following code can achieve the same mapping as
#' `aes_string(x_var, y_var)`.
Expand Down
2 changes: 1 addition & 1 deletion R/coord-radial.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
}
if (lifecycle::is_present(direction)) {
deprecate_warn0(
"3.5.2", "coord_radial(direction)", "coord_radial(reverse)"
"4.0.0", "coord_radial(direction)", "coord_radial(reverse)"

Check warning on line 139 in R/coord-radial.R

View check run for this annotation

Codecov / codecov/patch

R/coord-radial.R#L139

Added line #L139 was not covered by tests
)
reverse <- switch(reverse, "r" = "thetar", "theta")
}
Expand Down
2 changes: 1 addition & 1 deletion R/coord-transform.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
#' @export
coord_trans <- function(...) {
deprecate_soft0(
"3.5.2",
"4.0.0",

Check warning on line 116 in R/coord-transform.R

View check run for this annotation

Codecov / codecov/patch

R/coord-transform.R#L116

Added line #L116 was not covered by tests
"coord_trans()",
"coord_transform()"
)
Expand Down
2 changes: 1 addition & 1 deletion R/facet-wrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ wrap_layout <- function(id, dims, dir) {
# Should only occur when `as.table` was not incorporated into `dir`
dir <- switch(dir, h = "lt", v = "tl")
deprecate_soft0(
"3.5.2",
"4.0.0",
what = I("Internal use of `dir = \"h\"` and `dir = \"v\"` in `facet_wrap()`"),
details = I(c(
"The `dir` argument should incorporate the `as.table` argument.",
Expand Down
2 changes: 1 addition & 1 deletion R/geom-boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ GeomBoxplot <- ggproto("GeomBoxplot", Geom,
setup_params = function(data, params) {
if ("fatten" %in% names(params)) {
deprecate_soft0(
"3.6.0", "geom_boxplot(fatten)",
"4.0.0", "geom_boxplot(fatten)",
"geom_boxplot(median.linewidth)"
)
} else {
Expand Down
8 changes: 7 additions & 1 deletion R/geom-contour.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
#' @include geom-path.R
GeomContour <- ggproto(
"GeomContour", GeomPath,
default_aes = aes(weight = 1, !!!GeomPath$default_aes)
default_aes = aes(
weight = 1,
colour = from_theme(colour %||% accent),
linewidth = from_theme(linewidth),
linetype = from_theme(linetype),
alpha = NA
)
)

#' @rdname Geom
Expand Down
2 changes: 1 addition & 1 deletion R/geom-crossbar.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ GeomCrossbar <- ggproto("GeomCrossbar", Geom,
setup_params = function(data, params) {
if (lifecycle::is_present(params$fatten %||% deprecated())) {
deprecate_soft0(
"3.6.0", "geom_crossbar(fatten)",
"4.0.0", "geom_crossbar(fatten)",
"geom_crossbar(middle.linewidth)"
)
} else {
Expand Down
2 changes: 1 addition & 1 deletion R/geom-density.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ GeomDensity <- ggproto(
#' geom_density(position = "fill")
#' }
geom_density <- make_constructor(
GeomDensity, stat = "density",
GeomDensity, stat = "density", outline.type = "upper",
checks = exprs(
outline.type <- arg_match0(outline.type, c("both", "upper", "lower", "full"))
)
Expand Down
17 changes: 13 additions & 4 deletions R/geom-errorbar.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ GeomErrorbar <- ggproto(
required_aes = c("x|y", "ymin|xmin", "ymax|xmax"),

setup_params = function(data, params) {
GeomLinerange$setup_params(data, params)
params <- GeomLinerange$setup_params(data, params)
if (
isTRUE(params$flipped_aes) &&
isTRUE("height" %in% names(params)) &&
!isTRUE("width" %in% names(params))
) {
params <- rename(params, c(height = "width"))
cli::cli_inform("{.arg height} was translated to {.arg width}.")
}
params
},

extra_params = c("na.rm", "orientation"),
extra_params = c("na.rm", "orientation", "height"),

setup_data = function(self, data, params) {
data$flipped_aes <- params$flipped_aes
Expand Down Expand Up @@ -69,7 +78,7 @@ GeomErrorbarh <- ggproto(
"GeomErrorbarh", GeomErrorbar,
setup_params = function(data, params) {
deprecate_soft0(
"3.5.2", "geom_errobarh()", "geom_errorbar(orientation = \"y\")",
"4.0.0", "geom_errobarh()", "geom_errorbar(orientation = \"y\")",
id = "no-more-errorbarh"
)
GeomLinerange$setup_params(data, params)
Expand All @@ -87,7 +96,7 @@ geom_errorbar <- make_constructor(GeomErrorbar, orientation = NA)
#' `geom_errorbar(orientation = "y")` instead.
geom_errorbarh <- function(..., orientation = "y") {
deprecate_soft0(
"3.5.2", "geom_errobarh()", "geom_errorbar(orientation = \"y\")",
"4.0.0", "geom_errobarh()", "geom_errorbar(orientation = \"y\")",
id = "no-more-errorbarh"
)
geom_errorbar(..., orientation = orientation)
Expand Down
2 changes: 1 addition & 1 deletion R/geom-label.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

extra_args <- list2(...)
if (lifecycle::is_present(label.size)) {
deprecate_warn0("3.5.0", "geom_label(label.size)", "geom_label(linewidth)")
deprecate_soft0("3.5.0", "geom_label(label.size)", "geom_label(linewidth)")

Check warning on line 31 in R/geom-label.R

View check run for this annotation

Codecov / codecov/patch

R/geom-label.R#L31

Added line #L31 was not covered by tests
extra_args$linewidth <- extra_args$linewidth %||% label.size
}

Expand Down
2 changes: 1 addition & 1 deletion R/geom-path.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GeomPath <- ggproto("GeomPath", Geom,
required_aes = c("x", "y"),

default_aes = aes(
colour = from_theme(ink),
colour = from_theme(colour %||% ink),
linewidth = from_theme(linewidth),
linetype = from_theme(linetype),
alpha = NA
Expand Down
2 changes: 1 addition & 1 deletion R/geom-pointrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ GeomPointrange <- ggproto("GeomPointrange", Geom,

setup_params = function(data, params) {
if (lifecycle::is_present(params$fatten %||% deprecated())) {
deprecate_soft0("3.6.0", "geom_pointrange(fatten)", I("the `size` aesthetic"))
deprecate_soft0("4.0.0", "geom_pointrange(fatten)", I("the `size` aesthetic"))
} else {
# For backward compatibility reasons
params$fatten <- 4
Expand Down
2 changes: 1 addition & 1 deletion R/geom-violin.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
extra <- list()
if (lifecycle::is_present(draw_quantiles)) {
deprecate_soft0(
"3.6.0",
"4.0.0",

Check warning on line 114 in R/geom-violin.R

View check run for this annotation

Codecov / codecov/patch

R/geom-violin.R#L114

Added line #L114 was not covered by tests
what = "geom_violin(draw_quantiles)",
with = "geom_violin(quantiles.linetype)"
)
Expand Down
2 changes: 1 addition & 1 deletion R/guide-colorsteps.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ GuideColoursteps <- ggproto(
params$title <- scale$make_title(params$title, scale$name, title)

limits <- c(params$decor$min[1], params$decor$max[nrow(params$decor)])
if (params$reverse) {
if (isTRUE(params$reverse)) {
limits <- rev(limits)
}
params$key$.value <- rescale(params$key$.value, from = limits)
Expand Down
3 changes: 2 additions & 1 deletion R/guides-.R
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Guides <- ggproto(
#
# The resulting guide is then drawn in ggplot_gtable

build = function(self, scales, layers, labels, layer_data, theme = theme()) {
build = function(self, scales, layers, labels, layer_data, theme = NULL) {

# Empty guides list
custom <- self$get_custom()
Expand All @@ -300,6 +300,7 @@ Guides <- ggproto(
}

# Merge and process layers
theme <- theme %||% theme()
guides$merge()
guides$process_layers(layers, layer_data, theme)
if (length(guides$guides) == 0) {
Expand Down
5 changes: 3 additions & 2 deletions R/labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ setup_plot_labels <- function(plot, layers, data) {
# `geom_function()`. We can display these labels anyway, so we include them.
plot_labels <- plot@labels
known_labels <- c(names(labels), fn_fmls_names(labs), "x", "y")
extra_labels <- setdiff(names(plot_labels), known_labels)
extra_labels <- names(plot_labels)[lengths(plot_labels) > 0]
extra_labels <- setdiff(extra_labels, known_labels)

if (length(extra_labels) > 0) {

Expand All @@ -92,7 +93,7 @@ setup_plot_labels <- function(plot, layers, data) {
extra_labels <- paste0("{.field ", extra_labels, "} : ", warn_labels)
names(extra_labels) <- rep("*", length(extra_labels))

cli::cli_warn(c(
cli::cli_inform(c(
"Ignoring unknown labels:",
extra_labels
))
Expand Down
7 changes: 6 additions & 1 deletion R/layer-sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@
geom_column <- function(data) {
w <- which(vapply(data, inherits, TRUE, what = "sfc"))
if (length(w) == 0) {
"geometry" # avoids breaks when objects without geometry list-column are examined
if (!is.character(data[["geometry"]])) {
"geometry" # avoids breaks when objects without geometry list-column are examined
} else {
# Avoids a rare case where computed_geom_params$legend is present but there is no actual geometry column
""

Check warning on line 85 in R/layer-sf.R

View check run for this annotation

Codecov / codecov/patch

R/layer-sf.R#L85

Added line #L85 was not covered by tests
}
} else {
# this may not be best in case more than one geometry list-column is present:
if (length(w) > 1)
Expand Down
2 changes: 1 addition & 1 deletion R/layer.R
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ set_draw_key <- function(geom, draw_key = NULL) {
}
draw_key <- match.fun(draw_key)

ggproto("", geom, draw_key = draw_key)
ggproto(NULL, geom, draw_key = draw_key)
}

cleanup_mismatched_data <- function(data, n, fun) {
Expand Down
6 changes: 3 additions & 3 deletions R/plot-build.R
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,13 @@ S7::method(gtable_ggplot, class_ggplot_built) <- function(data) {
# TODO: the S3 generic should be phased out once S7 is adopted more widely
#' @rdname gtable_ggplot
#' @export
ggplot_gtable <- function(plot) {
ggplot_gtable <- function(data) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argument was data before, which I changed to plot because it felt more descriptive. However, this got us into trouble with S3 method/generic consistency.

UseMethod("ggplot_gtable")
}

#' @export
ggplot_gtable.default <- function(plot) {
gtable_ggplot(plot)
ggplot_gtable.default <- function(data) {
gtable_ggplot(data)
}

#' Generate a ggplot2 plot grob.
Expand Down
4 changes: 4 additions & 0 deletions R/plot-construction.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ S7::method(update_ggplot, list(S7::class_any, class_ggplot)) <-
function(object, plot, object_name, ...) {

if (!S7::S7_inherits(object) && inherits(object, "theme")) {
# This is a contingency for patchwork/#438
if (length(object) == 0) {
return(plot)
}
# For backward compatibility, we try to cast old S3 themes (lists with
# the class 'theme') to proper themes. People *should* use `theme()`,
# so we should be pushy here.
Expand Down
13 changes: 7 additions & 6 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,14 @@ S7::method(plot, class_ggplot) <- `print.ggplot2::ggplot`
`[[<-.ggplot2::gg` <- `$<-.ggplot2::gg`

#' @importFrom S7 convert
S7::method(convert, list(from = class_ggplot, to = S7::class_list)) <-
function(from, to) {
S7::props(from)
}

# S7 currently attaches the S3 method to the calling environment which gives `ggplot2:::as.list`
# Wrap in `local()` to provide a temp environment which throws away the attachment
local({
S7::method(as.list, class_ggplot) <- function(x, ...) convert(x, S7::class_list)
S7::method(convert, list(from = class_ggplot, to = S7::class_list)) <-
function(from, to) {
S7::props(from)
}

S7::method(as.list, class_ggplot) <-
function(x, ...) convert(x, S7::class_list)
})
2 changes: 1 addition & 1 deletion R/position-dodge.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ PositionDodge <- ggproto("PositionDodge", Position,
data$order <- xtfrm( # xtfrm makes anything 'sortable'
data$order %||% ave(data$group, data$x, data$PANEL, FUN = match_sorted)
)
if (params$reverse) {
if (isTRUE(params$reverse)) {
data$order <- -data$order
}
if (is.null(params$n)) { # preserve = "total"
Expand Down
2 changes: 1 addition & 1 deletion R/position-stack.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ PositionStack <- ggproto("PositionStack", Position,
flipped_aes <- has_flipped_aes(data)
data <- flip_data(data, flipped_aes)
var <- self$var %||% stack_var(data)
if (!vec_duplicate_any(data$x)) {
if (!vec_duplicate_any(data$x) && !isTRUE(self$fill)) {
# We skip stacking when all data have different x positions so that
# there is nothing to stack
var <- NULL
Expand Down
2 changes: 1 addition & 1 deletion R/scale-.R
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ ScaleDiscrete <- ggproto("ScaleDiscrete", Scale,
vec_slice(pal, match(as.character(x), limits, nomatch = vec_size(pal)))

if (!is.na(na_value)) {
vec_slice(pal_match, is.na(x)) <- na_value
vec_slice(pal_match, vec_detect_missing(x)) <- na_value
}
pal_match
},
Expand Down
2 changes: 1 addition & 1 deletion R/stat-summary-2d.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ StatSummary2d <- ggproto(
params$drop <- !identical(params$drop, "none")
}

params <- fix_bin_params(params, fun = snake_class(self), version = "3.5.2")
params <- fix_bin_params(params, fun = snake_class(self), version = "4.0.0")
vars <- c("origin", "binwidth", "breaks", "center", "boundary")
params[vars] <- lapply(params[vars], dual_param, default = NULL)
params$closed <- dual_param(params$closed, list(x = "right", y = "right"))
Expand Down
7 changes: 7 additions & 0 deletions R/stat-summary-bin.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ make_summary_fun <- function(fun.data, fun, fun.max, fun.min, fun.args) {
force(fun.min)
force(fun.args)

as_function <- function(x) {
if (is.character(x)) {
x <- match.fun(x)
}
rlang::as_function(x)
}

if (!is.null(fun.data)) {
# Function that takes complete data frame as input
fun.data <- as_function(fun.data)
Expand Down
2 changes: 1 addition & 1 deletion R/stat-ydensity.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ StatYdensity <- ggproto(

if (!is.null(params$draw_quantiles)) {
deprecate_soft0(
"3.6.0",
"4.0.0",
what = "stat_ydensity(draw_quantiles)",
with = "stat_ydensity(quantiles)"
)
Expand Down
Loading