Release 3.4.0 (#5025)

This commit is contained in:
Thomas Lin Pedersen 2022-10-31 14:28:09 +01:00 committed by GitHub
parent a58b48c961
commit 63125db184
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
80 changed files with 4863 additions and 405 deletions

View File

@ -1,5 +1,5 @@
Package: ggplot2
Version: 3.3.6.9000
Version: 3.4.0
Title: Create Elegant Data Visualisations Using the Grammar of Graphics
Authors@R: c(
person("Hadley", "Wickham", , "hadley@rstudio.com", role = "aut",
@ -43,7 +43,7 @@ Imports:
scales (>= 1.2.0),
stats,
tibble,
vctrs (>= 0.4.1),
vctrs (>= 0.5.0),
withr (>= 2.5.0)
Suggests:
covr,
@ -71,8 +71,6 @@ Suggests:
testthat (>= 3.1.2),
vdiffr (>= 1.0.0),
xml2
Remotes:
r-lib/lifecycle
Enhances:
sp
VignetteBuilder:

View File

@ -4,20 +4,23 @@ S3method("$",ggproto)
S3method("$",ggproto_parent)
S3method("$<-",uneval)
S3method("+",gg)
S3method("[",mapped_discrete)
S3method("[",uneval)
S3method("[<-",mapped_discrete)
S3method("[<-",uneval)
S3method("[[",ggproto)
S3method("[[<-",uneval)
S3method(.DollarNames,ggproto)
S3method(as.data.frame,mapped_discrete)
S3method(as.list,ggproto)
S3method(autolayer,default)
S3method(autoplot,default)
S3method(c,mapped_discrete)
S3method(drawDetails,zeroGrob)
S3method(element_grob,element_blank)
S3method(element_grob,element_line)
S3method(element_grob,element_rect)
S3method(element_grob,element_text)
S3method(format,ggplot2_mapped_discrete)
S3method(format,ggproto)
S3method(format,ggproto_method)
S3method(fortify,"NULL")
@ -139,30 +142,24 @@ S3method(scale_type,sfc)
S3method(single_value,default)
S3method(single_value,factor)
S3method(summary,ggplot)
S3method(vec_arith,ggplot2_mapped_discrete)
S3method(vec_arith.ggplot2_mapped_discrete,MISSING)
S3method(vec_arith.ggplot2_mapped_discrete,default)
S3method(vec_arith.ggplot2_mapped_discrete,ggplot2_mapped_discrete)
S3method(vec_arith.ggplot2_mapped_discrete,numeric)
S3method(vec_arith.numeric,ggplot2_mapped_discrete)
S3method(vec_cast,character.ggplot2_mapped_discrete)
S3method(vec_cast,double.ggplot2_mapped_discrete)
S3method(vec_cast,factor.ggplot2_mapped_discrete)
S3method(vec_cast,ggplot2_mapped_discrete.double)
S3method(vec_cast,ggplot2_mapped_discrete.factor)
S3method(vec_cast,ggplot2_mapped_discrete.ggplot2_mapped_discrete)
S3method(vec_cast,ggplot2_mapped_discrete.integer)
S3method(vec_cast,integer.ggplot2_mapped_discrete)
S3method(vec_math,ggplot2_mapped_discrete)
S3method(vec_ptype2,character.ggplot2_mapped_discrete)
S3method(vec_ptype2,double.ggplot2_mapped_discrete)
S3method(vec_ptype2,factor.ggplot2_mapped_discrete)
S3method(vec_ptype2,ggplot2_mapped_discrete.character)
S3method(vec_ptype2,ggplot2_mapped_discrete.double)
S3method(vec_ptype2,ggplot2_mapped_discrete.factor)
S3method(vec_ptype2,ggplot2_mapped_discrete.ggplot2_mapped_discrete)
S3method(vec_ptype2,ggplot2_mapped_discrete.integer)
S3method(vec_ptype2,integer.ggplot2_mapped_discrete)
S3method(vec_cast,character.mapped_discrete)
S3method(vec_cast,double.mapped_discrete)
S3method(vec_cast,factor.mapped_discrete)
S3method(vec_cast,integer.mapped_discrete)
S3method(vec_cast,mapped_discrete.double)
S3method(vec_cast,mapped_discrete.factor)
S3method(vec_cast,mapped_discrete.integer)
S3method(vec_cast,mapped_discrete.logical)
S3method(vec_cast,mapped_discrete.mapped_discrete)
S3method(vec_ptype2,character.mapped_discrete)
S3method(vec_ptype2,double.mapped_discrete)
S3method(vec_ptype2,factor.mapped_discrete)
S3method(vec_ptype2,integer.mapped_discrete)
S3method(vec_ptype2,mapped_discrete.character)
S3method(vec_ptype2,mapped_discrete.double)
S3method(vec_ptype2,mapped_discrete.factor)
S3method(vec_ptype2,mapped_discrete.integer)
S3method(vec_ptype2,mapped_discrete.mapped_discrete)
S3method(widthDetails,titleGrob)
S3method(widthDetails,zeroGrob)
export("%+%")
@ -691,7 +688,6 @@ export(update_geom_defaults)
export(update_labels)
export(update_stat_defaults)
export(vars)
export(vec_arith.ggplot2_mapped_discrete)
export(waiver)
export(wrap_dims)
export(xlab)

127
NEWS.md
View File

@ -1,19 +1,64 @@
# ggplot2 (development version)
# ggplot2 3.4.0
This is a minor release focusing on tightening up the internals and ironing out
some inconsistencies in the API. The biggest change is the addition of the
`linewidth` aesthetic that takes of sizing the width of any line from `size`.
This change, while attempting to be as non-breaking as possible, has the
potential to change the look of some of your plots.
Other notable changes is a complete redo of the error and warning messaging in
ggplot2 using the cli package. Messaging is now better contextualised and it
should be easier to identify which layer an error is coming from. Last, we have
now made the switch to using the vctrs package internally which means that
support for vctrs classes as variables should improve, along with some small
gains in rendering speed.
## Breaking changes
* A `linewidth` aesthetic has been introduced and supersedes the `size`
aesthetic for scaling the width of lines in line based geoms. `size` will
remain functioning but deprecated for these geoms and it is recommended to
update all code to reflect the new aesthetic. For geoms that have _both_ point
sizing and linewidth sizing (`geom_pointrange()` and `geom_sf`) `size` now
**only** refers to sizing of points which can leads to a visual change in old
code (@thomasp85, #3672)
* The default line width for polygons in `geom_sf()` have been decreased to 0.2
to reflect that this is usually used for demarking borders where a thinner
line is better suited. This change was made since we already induced a
visual change in `geom_sf()` with the introduction of the `linewidth`
aesthetic.
* The dot-dot notation (`..var..`) and `stat()`, which have been superseded by
`after_stat()`, are now formally deprecated (@yutannihilation, #3693).
* `qplot()` is now formally deprecated (@yutannihilation, #3956).
* `stage()` now properly refers to the values without scale transformations for
the stage of `after_stat`. If your code requires the scaled version of the
values for some reason, you have to apply the same transformation by yourself,
e.g. `sqrt()` for `scale_{x,y}_sqrt()` (@yutannihilation and @teunbrand, #4155).
* Use `rlang::hash()` instead of `digest::digest()`. This update may lead to
changes in the automatic sorting of legends. In order to enforce a specific
legend order use the `order` argument in the guide. (@thomasp85, #4458)
* referring to `x` in backquoted expressions with `label_bquote()` is no longer
possible.
* The `ticks.linewidth` and `frame.linewidth` parameters of `guide_colourbar()`
are now multiplied with `.pt` like elsewhere in ggplot2. It can cause visual
changes when these arguments are not the defaults and these changes can be
restored to their previous behaviour by adding `/ .pt` (@teunbrand #4314).
* `scale_*_viridis_b()` now uses the full range of the viridis scales
(@gregleleu, #4737)
## New features
* `geom_col()` and `geom_bar()` gain a new `just` argument. This is set to `0.5`
by default; use `just = 0`/`just = 1` to place columns on the left/right
of the axis breaks.
(@wurli, #4899)
* Fix a bug in `position_jitter()` where infinity values were dropped (@javlon,
#4790).
* `geom_linerange()` now respects the `na.rm` argument (#4927, @thomasp85)
* Improve the support for `guide_axis()` on `coord_trans()` (@yutannihilation, #3959)
* `geom_density()` and `stat_density()` now support `bounds` argument
to estimate density with boundary correction (@echasnovski, #4013).
@ -22,6 +67,25 @@
columns were dropped and warns about this. If stats intend to drop
data columns they can declare them in the new field `dropped_aes`.
(@clauswilke, #3250)
* `...` supports `rlang::list2` dynamic dots in all public functions.
(@mone27, #4764)
* `theme()` now has a `strip.clip` argument, that can be set to `"off"` to
prevent the clipping of strip text and background borders (@teunbrand, #4118)
* `geom_contour()` now accepts a function in the `breaks` argument
(@eliocamp, #4652).
## Minor improvements and bug fixes
* Fix a bug in `position_jitter()` where infinity values were dropped (@javlon,
#4790).
* `geom_linerange()` now respects the `na.rm` argument (#4927, @thomasp85)
* Improve the support for `guide_axis()` on `coord_trans()`
(@yutannihilation, #3959)
* Added `stat_align()` to align data without common x-coordinates prior to
stacking. This is now the default stat for `geom_area()` (@thomasp85, #4850)
@ -30,26 +94,11 @@
certain number of digits would cause the computations to fail (@thomasp85,
#4874)
* `stage()` now properly refers to the values without scale transformations for
the stage of `after_stat`. If your code requires the scaled version of the
values for some reason, you have to apply the same transformation by yourself,
e.g. `sqrt()` for `scale_{x,y}_sqrt()` (@yutannihilation and @teunbrand, #4155).
* A `linewidth` aesthetic has been introduced and supersedes the `size`
aesthetic for scaling the width of lines in line based geoms. `size` will
remain functioning but deprecated for these geoms and it is recommended to
update all code to reflect the new aesthetic (@thomasp85, #3672)
* Secondary axis ticks are now positioned more precisely, removing small visual
artefacts with alignment between grid and ticks (@thomasp85, #3576)
* Improve `stat_function` documentation regarding `xlim` argument. (@92amartins, #4474)
* `qplot()` is now formally deprecated (@yutannihilation, #3956).
* Use `rlang::hash()` instead of `digest::digest()`. This update may lead to
changes in the automatic sorting of legends. In order to enforce a specific
legend order use the `order` argument in the guide. (@thomasp85, #4458)
* Improve `stat_function` documentation regarding `xlim` argument.
(@92amartins, #4474)
* Fix various issues with how `labels`, `breaks`, `limits`, and `show.limits`
interact in the different binning guides (@thomasp85, #4831)
@ -62,11 +111,6 @@
If used incorrectly, the warning will now report the duplicated aesthetic
instead of `NA` (@teunbrand, #4707).
* `...` supports `rlang::list2` dynamic dots in all public functions. (@mone27, #4764)
* `theme()` now has a `strip.clip` argument, that can be set to `"off"` to
prevent the clipping of strip text and background borders (@teunbrand, #4118)
* `aes()` now supports the `!!!` operator in its first two arguments
(#2675). Thanks to @yutannihilation and @teunbrand for draft
implementations.
@ -81,9 +125,6 @@
* `presidential` dataset now includes Trump's presidency (@bkmgit, #4703).
* referring to `x` in backquoted expressions with `label_bquote()` is no longer
possible.
* `position_stack()` now works fully with `geom_text()` (@thomasp85, #4367)
* `geom_tile()` now correctly recognises missing data in `xmin`, `xmax`, `ymin`,
@ -106,8 +147,9 @@
* Binning scales are now more resilient to calculated limits that ends up being
`NaN` after transformations (@thomasp85, #4510)
* Strip padding in `facet_grid()` is now only in effect if `strip.placement = "outside"`
_and_ an axis is present between the strip and the panel (@thomasp85, #4610)
* Strip padding in `facet_grid()` is now only in effect if
`strip.placement = "outside"` _and_ an axis is present between the strip and
the panel (@thomasp85, #4610)
* Aesthetics of length 1 are now recycled to 0 if the length of the data is 0
(@thomasp85, #4588)
@ -134,18 +176,9 @@
all `values` on the legend instead, use
`scale_*_manual(values = vals, limits = names(vals))`. (@teunbrand, @banfai,
#4511, #4534)
* `geom_contour()` now accepts a function in the `breaks` argument (@eliocamp, #4652).
* VISUAL CHANGE: `scale_*_viridis_b()` now uses the full range of the viridis scales (@gregleleu, #4737)
* Updated documentation for `geom_contour()` to correctly reflect argument
precedence between `bins` and `binwidth`. (@eliocamp, #4651)
* The `ticks.linewidth` and `frame.linewidth` parameters of `guide_colourbar()`
are now multiplied with `.pt` like elsewhere in ggplot2. It can cause visual
changes when these arguments are not the defaults and these changes can be
restored to their previous behaviour by adding `/ .pt` (@teunbrand #4314).
precedence between `bins` and `binwidth`. (@eliocamp, #4651)
* Dots in `geom_dotplot()` are now correctly aligned to the baseline when
`stackratio != 1` and `stackdir != "up"` (@mjskay, #4614)
@ -153,8 +186,8 @@ precedence between `bins` and `binwidth`. (@eliocamp, #4651)
* Key glyphs for `geom_boxplot()`, `geom_crossbar()`, `geom_pointrange()`, and
`geom_linerange()` are now orientation-aware (@mjskay, #4732)
* Updated documentation for `geom_smooth()` to more clearly describe effects of the
`fullrange` parameter (@thoolihan, #4399).
* Updated documentation for `geom_smooth()` to more clearly describe effects of
the `fullrange` parameter (@thoolihan, #4399).
# ggplot2 3.3.6
This is a very small release only applying an internal change to comply with

View File

@ -115,7 +115,7 @@ is_calculated <- function(x, warn = FALSE) {
what <- I(glue("The dot-dot notation (`{x}`)"))
var <- gsub(match_calculated_aes, "\\1", as.character(x))
with <- I(glue("`after_stat({var})`"))
lifecycle::deprecate_warn("3.4.0", what, with, id = "ggplot-warn-aes-dot-dot")
deprecate_warn0("3.4.0", what, with, id = "ggplot-warn-aes-dot-dot")
}
res
} else if (is_quosure(x)) {
@ -126,7 +126,7 @@ is_calculated <- function(x, warn = FALSE) {
what <- I(glue("`{expr_deparse(x)}`"))
x[[1]] <- quote(after_stat)
with <- I(glue("`{expr_deparse(x)}`"))
lifecycle::deprecate_warn("3.4.0", what, with, id = "ggplot-warn-aes-stat")
deprecate_warn0("3.4.0", what, with, id = "ggplot-warn-aes-stat")
}
TRUE
} else {

10
R/aes.r
View File

@ -208,8 +208,8 @@ standardise_aes_symbols <- function(x) {
# Look up the scale that should be used for a given aesthetic
aes_to_scale <- function(var) {
var[var %in% c("x", "xmin", "xmax", "xend", "xintercept")] <- "x"
var[var %in% c("y", "ymin", "ymax", "yend", "yintercept")] <- "y"
var[var %in% ggplot_global$x_aes] <- "x"
var[var %in% ggplot_global$y_aes] <- "y"
var
}
@ -265,7 +265,7 @@ is_position_aes <- function(vars) {
#'
#' @export
aes_ <- function(x, y, ...) {
lifecycle::deprecate_soft(
deprecate_soft0(
"3.0.0",
"aes_()",
details = "Please use tidy evaluation ideoms with `aes()`"
@ -292,7 +292,7 @@ aes_ <- function(x, y, ...) {
#' @rdname aes_
#' @export
aes_string <- function(x, y, ...) {
lifecycle::deprecate_soft(
deprecate_soft0(
"3.0.0",
"aes_string()",
details = "Please use tidy evaluation ideoms with `aes()`"
@ -346,7 +346,7 @@ aes_all <- function(vars) {
#' @keywords internal
#' @export
aes_auto <- function(data = NULL, ...) {
lifecycle::deprecate_warn("2.0.0", "aes_auto()")
deprecate_warn0("2.0.0", "aes_auto()")
# detect names of data
if (is.null(data)) {

View File

@ -42,7 +42,7 @@ annotate <- function(geom, x = NULL, y = NULL, xmin = NULL, xmax = NULL,
ymin = NULL, ymax = NULL, xend = NULL, yend = NULL, ...,
na.rm = FALSE) {
if (geom %in% c("abline", "hline", "vline")) {
if (is.character(geom) && geom %in% c("abline", "hline", "vline")) {
cli::cli_warn(c(
"{.arg geom} must not be {.val {geom}}.",
"i" = "Please use {.fn {paste0('geom_', geom)}} directly instead."

View File

@ -159,7 +159,7 @@ count <- function(df, vars = NULL, wt_var = NULL) {
# Create a shared unique id across two data frames such that common variable
# combinations in the two data frames gets the same id
join_keys <- function(x, y, by) {
joint <- vec_rbind(x[by], y[by])
joint <- vec_rbind0(x[by], y[by])
keys <- id(joint, drop = TRUE)
n_x <- nrow(x)
n_y <- nrow(y)
@ -298,7 +298,7 @@ dapply <- function(df, by, fun, ..., drop = TRUE) {
cur_data <- df_rows(df, group_rows[[i]])
apply_fun(cur_data)
})
vec_rbind(!!!result)
vec_rbind0(!!!result)
}
single_value <- function(x, ...) {

View File

@ -62,7 +62,7 @@ Coord <- ggproto("Coord",
labels = function(self, labels, panel_params) {
# If panel params contains guides information, use it.
# Otherwise use the labels as is, for backward-compatibility
if (is.null(panel_params$guide)) {
if (is.null(panel_params$guides)) {
return(labels)
}

View File

@ -78,11 +78,11 @@
coord_trans <- function(x = "identity", y = "identity", xlim = NULL, ylim = NULL,
limx = deprecated(), limy = deprecated(), clip = "on", expand = TRUE) {
if (lifecycle::is_present(limx)) {
lifecycle::deprecate_warn("3.3.0", "coord_trans(limx)", "coord_trans(xlim)")
deprecate_warn0("3.3.0", "coord_trans(limx)", "coord_trans(xlim)")
xlim <- limx
}
if (lifecycle::is_present(limy)) {
lifecycle::deprecate_warn("3.3.0", "coord_trans(limy)", "coord_trans(ylim)")
deprecate_warn0("3.3.0", "coord_trans(limy)", "coord_trans(ylim)")
ylim <- limy
}

View File

@ -317,7 +317,9 @@ validate_facets <- function(x) {
if (inherits(x, "uneval")) {
cli::cli_abort("Please use {.fn vars} to supply facet variables")
}
if (inherits(x, "ggplot")) {
# Native pipe have higher precedence than + so any type of gg object can be
# expected here, not just ggplot
if (inherits(x, "gg")) {
cli::cli_abort(c(
"Please use {.fn vars} to supply facet variables",
"i" = "Did you use {.code %>%} or {.code |>} instead of {.code +}?"
@ -596,7 +598,7 @@ combine_vars <- function(data, env = emptyenv(), vars = NULL, drop = TRUE) {
))
}
base <- unique0(vec_rbind(!!!values[has_all]))
base <- unique0(vec_rbind0(!!!values[has_all]))
if (!drop) {
base <- unique_combs(base)
}
@ -610,7 +612,7 @@ combine_vars <- function(data, env = emptyenv(), vars = NULL, drop = TRUE) {
if (drop) {
new <- unique_combs(new)
}
base <- unique0(vec_rbind(base, df.grid(old, new)))
base <- unique0(vec_rbind0(base, df.grid(old, new)))
}
if (empty(base)) {

View File

@ -123,13 +123,13 @@ facet_grid <- function(rows = NULL, cols = NULL, scales = "fixed",
cols <- NULL
}
scales <- arg_match0(scales, c("fixed", "free_x", "free_y", "free"))
scales <- arg_match0(scales %||% "fixed", c("fixed", "free_x", "free_y", "free"))
free <- list(
x = any(scales %in% c("free_x", "free")),
y = any(scales %in% c("free_y", "free"))
)
space <- arg_match0(space, c("fixed", "free_x", "free_y", "free"))
space <- arg_match0(space %||% "fixed", c("fixed", "free_x", "free_y", "free"))
space_free <- list(
x = any(space %in% c("free_x", "free")),
y = any(space %in% c("free_y", "free"))
@ -158,7 +158,9 @@ grid_as_facets_list <- function(rows, cols) {
if (!is_rows_vars) {
if (!is.null(cols)) {
msg <- "{.arg rows} must be {.val NULL} or a {.fn vars} list if {.arg cols} is a {.fn vars} list"
if (inherits(rows, "ggplot")) {
# Native pipe have higher precedence than + so any type of gg object can be
# expected here, not just ggplot
if (inherits(rows, "gg")) {
msg <- c(
msg,
"i" = "Did you use {.code %>%} or {.code |>} instead of {.code +}?"

View File

@ -81,7 +81,7 @@ facet_wrap <- function(facets, nrow = NULL, ncol = NULL, scales = "fixed",
shrink = TRUE, labeller = "label_value", as.table = TRUE,
switch = deprecated(), drop = TRUE, dir = "h",
strip.position = 'top') {
scales <- arg_match0(scales, c("fixed", "free_x", "free_y", "free"))
scales <- arg_match0(scales %||% "fixed", c("fixed", "free_x", "free_y", "free"))
dir <- arg_match0(dir, c("h", "v"))
free <- list(
x = any(scales %in% c("free_x", "free")),
@ -94,8 +94,8 @@ facet_wrap <- function(facets, nrow = NULL, ncol = NULL, scales = "fixed",
# Flatten all facets dimensions into a single one
facets <- wrap_as_facets_list(facets)
if (lifecycle::is_present(switch)) {
lifecycle::deprecate_warn("2.2.0", "facet_wrap(switch)", "facet_wrap(strip.position)")
if (lifecycle::is_present(switch) && !is.null(switch)) {
deprecate_warn0("2.2.0", "facet_wrap(switch)", "facet_wrap(strip.position)")
strip.position <- if (switch == "x") "bottom" else "left"
}
strip.position <- arg_match0(strip.position, c("top", "bottom", "left", "right"))

View File

@ -26,7 +26,7 @@ fortify.SpatialPolygonsDataFrame <- function(model, data, region = NULL, ...) {
# If not specified, split into regions based on polygons
if (is.null(region)) {
coords <- lapply(model@polygons,fortify)
coords <- vec_rbind(!!!coords)
coords <- vec_rbind0(!!!coords)
cli::cli_inform("Regions defined for each Polygons")
} else {
cp <- sp::polygons(model)
@ -44,7 +44,7 @@ fortify.SpatialPolygonsDataFrame <- function(model, data, region = NULL, ...) {
#' @method fortify SpatialPolygons
fortify.SpatialPolygons <- function(model, data, ...) {
polys <- lapply(model@polygons, fortify)
vec_rbind(!!!polys)
vec_rbind0(!!!polys)
}
#' @rdname fortify.sp
@ -57,7 +57,7 @@ fortify.Polygons <- function(model, data, ...) {
df$piece <- i
df
})
pieces <- vec_rbind(!!!pieces)
pieces <- vec_rbind0(!!!pieces)
pieces$order <- 1:nrow(pieces)
pieces$id <- model@ID
@ -82,7 +82,7 @@ fortify.Polygon <- function(model, data, ...) {
#' @method fortify SpatialLinesDataFrame
fortify.SpatialLinesDataFrame <- function(model, data, ...) {
lines <- lapply(model@lines, fortify)
vec_rbind(!!!lines)
vec_rbind0(!!!lines)
}
#' @rdname fortify.sp
@ -95,7 +95,7 @@ fortify.Lines <- function(model, data, ...) {
df$piece <- i
df
})
pieces <- vec_rbind(!!!pieces)
pieces <- vec_rbind0(!!!pieces)
pieces$order <- 1:nrow(pieces)
pieces$id <- model@ID

View File

@ -107,15 +107,23 @@ Geom <- ggproto("Geom",
# Combine data with defaults and set aesthetics from parameters
use_defaults = function(self, data, params = list(), modifiers = aes()) {
default_aes <- self$default_aes
# Inherit size as linewidth if no linewidth aesthetic and param exist
if (self$rename_size && is.null(data$linewidth) && is.null(params$linewidth)) {
data$linewidth <- data$size
params$linewidth <- params$size
}
# Take care of subclasses setting the wrong default when inheriting from
# a geom with rename_size = TRUE
if (self$rename_size && is.null(default_aes$linewidth)) {
deprecate_soft0("3.4.0", I("Using the `size` aesthetic in this geom"), I("`linewidth` in the `default_aes` field and elsewhere"))
default_aes$linewidth <- default_aes$size
}
# Fill in missing aesthetics with their defaults
missing_aes <- setdiff(names(self$default_aes), names(data))
missing_aes <- setdiff(names(default_aes), names(data))
missing_eval <- lapply(self$default_aes[missing_aes], eval_tidy)
missing_eval <- lapply(default_aes[missing_aes], eval_tidy)
# Needed for geoms with defaults set to NULL (e.g. GeomSf)
missing_eval <- compact(missing_eval)
@ -229,3 +237,11 @@ check_aesthetics <- function(x, n) {
"x" = "Fix the following mappings: {.col {names(which(!good))}}"
))
}
check_linewidth <- function(data, name) {
if (is.null(data$linewidth) && !is.null(data$size)) {
deprecate_soft0("3.4.0", I(paste0("Using the `size` aesthietic with ", name)), I("the `linewidth` aesthetic"))
data$linewidth <- data$size
}
data
}

View File

@ -148,7 +148,7 @@ GeomBar <- ggproto("GeomBar", GeomRect,
data$just <- params$just %||% 0.5
data <- transform(data,
ymin = pmin(y, 0), ymax = pmax(y, 0),
xmin = x - width * (1 - just), xmax = x + width * just,
xmin = x - width * just, xmax = x + width * (1 - just),
width = NULL, just = NULL
)
flip_data(data, params$flipped_aes)

View File

@ -212,6 +212,7 @@ GeomBoxplot <- ggproto("GeomBoxplot", Geom,
outlier.size = 1.5, outlier.stroke = 0.5,
outlier.alpha = NULL, notch = FALSE, notchwidth = 0.5,
varwidth = FALSE, flipped_aes = FALSE) {
data <- check_linewidth(data, snake_class(self))
data <- flip_data(data, flipped_aes)
# this may occur when using geom_boxplot(stat = "identity")
if (nrow(data) != 1) {

View File

@ -47,9 +47,10 @@ GeomCrossbar <- ggproto("GeomCrossbar", Geom,
draw_key = draw_key_crossbar,
draw_panel = function(data, panel_params, coord, lineend = "butt",
draw_panel = function(self, data, panel_params, coord, lineend = "butt",
linejoin = "mitre", fatten = 2.5, width = NULL,
flipped_aes = FALSE) {
data <- check_linewidth(data, snake_class(self))
data <- flip_data(data, flipped_aes)
middle <- transform(data, x = xmin, xend = xmax, yend = y, linewidth = linewidth * fatten, alpha = NA)

View File

@ -52,7 +52,9 @@ GeomErrorbar <- ggproto("GeomErrorbar", Geom,
flip_data(data, params$flipped_aes)
},
draw_panel = function(data, panel_params, coord, lineend = "butt", width = NULL, flipped_aes = FALSE) {
draw_panel = function(self, data, panel_params, coord, lineend = "butt",
width = NULL, flipped_aes = FALSE) {
data <- check_linewidth(data, snake_class(self))
data <- flip_data(data, flipped_aes)
x <- vec_interleave(data$xmin, data$xmax, NA, data$x, data$x, NA, data$xmin, data$xmax)
y <- vec_interleave(data$ymax, data$ymax, NA, data$ymax, data$ymin, NA, data$ymin, data$ymin)

View File

@ -67,7 +67,8 @@ GeomErrorbarh <- ggproto("GeomErrorbarh", Geom,
)
},
draw_panel = function(data, panel_params, coord, height = NULL, lineend = "butt") {
draw_panel = function(self, data, panel_params, coord, height = NULL, lineend = "butt") {
data <- check_linewidth(data, snake_class(self))
GeomPath$draw_panel(data_frame0(
x = vec_interleave(data$xmax, data$xmax, NA, data$xmax, data$xmin, NA, data$xmin, data$xmin),
y = vec_interleave(data$ymin, data$ymax, NA, data$y, data$y, NA, data$ymin, data$ymax),

View File

@ -54,8 +54,9 @@ geom_hex <- function(mapping = NULL, data = NULL,
#' @usage NULL
#' @export
GeomHex <- ggproto("GeomHex", Geom,
draw_group = function(data, panel_params, coord, lineend = "butt",
draw_group = function(self, data, panel_params, coord, lineend = "butt",
linejoin = "mitre", linemitre = 10) {
data <- check_linewidth(data, snake_class(self))
if (empty(data)) {
return(zeroGrob())
}

View File

@ -135,7 +135,7 @@ GeomPath <- ggproto("GeomPath", Geom,
handle_na = function(self, data, params) {
# Drop missing values at the start or end of a line - can't drop in the
# middle since you expect those to be shown by a break in the line
complete <- stats::complete.cases(data[c("x", "y", "linewidth", "colour", "linetype")])
complete <- stats::complete.cases(data[names(data) %in% c("x", "y", "linewidth", "colour", "linetype")])
kept <- stats::ave(complete, data$group, FUN = keep_mid_true)
data <- data[kept, ]
@ -149,6 +149,7 @@ GeomPath <- ggproto("GeomPath", Geom,
draw_panel = function(self, data, panel_params, coord, arrow = NULL,
lineend = "butt", linejoin = "round", linemitre = 10,
na.rm = FALSE) {
data <- check_linewidth(data, snake_class(self))
if (!anyDuplicated(data$group)) {
cli::cli_inform(c(
"{.fn {snake_class(self)}}: Each group consists of only one observation.",
@ -170,7 +171,7 @@ GeomPath <- ggproto("GeomPath", Geom,
linetype <- unique0(df$linetype)
data_frame0(
solid = identical(linetype, 1) || identical(linetype, "solid"),
constant = nrow(unique0(df[, c("alpha", "colour", "linewidth", "linetype")])) == 1,
constant = nrow(unique0(df[, names(df) %in% c("alpha", "colour", "linewidth", "linetype")])) == 1,
.size = 1
)
})

View File

@ -107,8 +107,9 @@ geom_polygon <- function(mapping = NULL, data = NULL,
#' @usage NULL
#' @export
GeomPolygon <- ggproto("GeomPolygon", Geom,
draw_panel = function(data, panel_params, coord, rule = "evenodd", lineend = "butt",
linejoin = "round", linemitre = 10) {
draw_panel = function(self, data, panel_params, coord, rule = "evenodd",
lineend = "butt", linejoin = "round", linemitre = 10) {
data <- check_linewidth(data, snake_class(self))
n <- nrow(data)
if (n == 1) return(zeroGrob())

View File

@ -34,6 +34,7 @@ GeomRect <- ggproto("GeomRect", Geom,
required_aes = c("xmin", "xmax", "ymin", "ymax"),
draw_panel = function(self, data, panel_params, coord, lineend = "butt", linejoin = "mitre") {
data <- check_linewidth(data, snake_class(self))
if (!coord$is_linear()) {
aesthetics <- setdiff(
names(data), c("x", "y", "xmin", "xmax", "ymin", "ymax")

View File

@ -119,15 +119,16 @@ GeomRibbon <- ggproto("GeomRibbon", Geom,
data
},
draw_group = function(data, panel_params, coord, lineend = "butt",
draw_group = function(self, data, panel_params, coord, lineend = "butt",
linejoin = "round", linemitre = 10, na.rm = FALSE,
flipped_aes = FALSE, outline.type = "both") {
data <- check_linewidth(data, snake_class(self))
data <- flip_data(data, flipped_aes)
if (na.rm) data <- data[stats::complete.cases(data[c("x", "ymin", "ymax")]), ]
data <- data[order(data$group), ]
# Check that aesthetics are constant
aes <- unique0(data[c("colour", "fill", "linewidth", "linetype", "alpha")])
aes <- unique0(data[names(data) %in% c("colour", "fill", "linewidth", "linetype", "alpha")])
if (nrow(aes) > 1) {
cli::cli_abort("Aesthetics can not vary along a ribbon")
}
@ -168,7 +169,7 @@ GeomRibbon <- ggproto("GeomRibbon", Geom,
munched_upper <- coord_munch(coord, positions_upper, panel_params)
munched_lower <- coord_munch(coord, positions_lower, panel_params)
munched_poly <- vec_rbind(munched_upper, munched_lower)
munched_poly <- vec_rbind0(munched_upper, munched_lower)
is_full_outline <- identical(outline.type, "full")
g_poly <- polygonGrob(
@ -193,7 +194,7 @@ GeomRibbon <- ggproto("GeomRibbon", Geom,
munched_lower$id <- munched_lower$id + max(ids, na.rm = TRUE)
munched_lines <- switch(outline.type,
both = vec_rbind(munched_upper, munched_lower),
both = vec_rbind0(munched_upper, munched_lower),
upper = munched_upper,
lower = munched_lower,
cli::cli_abort(c(

View File

@ -88,8 +88,9 @@ geom_rug <- function(mapping = NULL, data = NULL,
GeomRug <- ggproto("GeomRug", Geom,
optional_aes = c("x", "y"),
draw_panel = function(data, panel_params, coord, lineend = "butt", sides = "bl",
outside = FALSE, length = unit(0.03, "npc")) {
draw_panel = function(self, data, panel_params, coord, lineend = "butt",
sides = "bl", outside = FALSE, length = unit(0.03, "npc")) {
data <- check_linewidth(data, snake_class(self))
if (!inherits(length, "unit")) {
cli::cli_abort("{.arg length} must be a {.cls unit} object.")
}

View File

@ -107,6 +107,7 @@ GeomSegment <- ggproto("GeomSegment", Geom,
default_aes = aes(colour = "black", linewidth = 0.5, linetype = 1, alpha = NA),
draw_panel = function(self, data, panel_params, coord, arrow = NULL, arrow.fill = NULL,
lineend = "butt", linejoin = "round", na.rm = FALSE) {
data <- check_linewidth(data, snake_class(self))
data <- remove_missing(data, na.rm = na.rm,
c("x", "y", "xend", "yend", "linetype", "linewidth", "shape"),
name = "geom_segment"
@ -135,7 +136,7 @@ GeomSegment <- ggproto("GeomSegment", Geom,
starts <- subset(data, select = c(-xend, -yend))
ends <- rename(subset(data, select = c(-x, -y)), c("xend" = "x", "yend" = "y"))
pieces <- vec_rbind(starts, ends)
pieces <- vec_rbind0(starts, ends)
pieces <- pieces[order(pieces$group),]
GeomPath$draw_panel(pieces, panel_params, coord, arrow = arrow,

View File

@ -185,7 +185,7 @@ sf_grob <- function(x, lineend = "butt", linejoin = "round", linemitre = 10,
defaults <- list(
GeomPoint$default_aes,
GeomLine$default_aes,
modify_list(GeomPolygon$default_aes, list(fill = "grey90", colour = "grey35"))
modify_list(GeomPolygon$default_aes, list(fill = "grey90", colour = "grey35", linewidth = 0.2))
)
defaults[[4]] <- modify_list(
defaults[[3]],

View File

@ -47,7 +47,7 @@ geom_spoke <- function(mapping = NULL, data = NULL,
#' @rdname geom_spoke
#' @usage NULL
stat_spoke <- function(...) {
lifecycle::deprecate_warn("2.0.0", "stat_spoke()", "geom_spoke()")
deprecate_warn0("2.0.0", "stat_spoke()", "geom_spoke()")
geom_spoke(...)
}

View File

@ -144,14 +144,14 @@ GeomViolin <- ggproto("GeomViolin", Geom,
)
# Make sure it's sorted properly to draw the outline
newdata <- vec_rbind(
newdata <- vec_rbind0(
transform(data, x = xminv)[order(data$y), ],
transform(data, x = xmaxv)[order(data$y, decreasing = TRUE), ]
)
# Close the polygon: set first and last point the same
# Needed for coord_polar and such
newdata <- vec_rbind(newdata, newdata[1,])
newdata <- vec_rbind0(newdata, newdata[1,])
newdata <- flip_data(newdata, flipped_aes)
# Draw quantiles if requested, so long as there is non-zero y range

View File

@ -72,7 +72,7 @@ guides <- function(...) {
idx_false <- vapply(args, isFALSE, FUN.VALUE = logical(1L))
if (isTRUE(any(idx_false))) {
lifecycle::deprecate_warn("3.3.4", "guides(`<scale>` = 'cannot be `FALSE`. Use \"none\" instead')")
deprecate_warn0("3.3.4", "guides(`<scale>` = 'cannot be `FALSE`. Use \"none\" instead')")
args[idx_false] <- "none"
}
@ -200,14 +200,7 @@ guides_train <- function(scales, theme, guides, labels) {
if (identical(guide, "none") || inherits(guide, "guide_none")) next
if (isFALSE(guide)) {
# lifecycle currently doesn't support function name placeholders.
# the below gives us the correct behaviour but is too brittle and hacky
# lifecycle::deprecate_warn("3.3.4", "`scale_*()`(guide = 'cannot be `FALSE`. Use \"none\" instead')")
# TODO: update to lifecycle after next lifecycle release
cli::cli_warn(c(
"{.code guide = FALSE} is deprecated",
"i" = 'Please use {.code guide = "none"} instead.'
))
deprecate_warn0("3.3.4", I("The `guide` argument in `scale_*()` cannot be `FALSE`. This "), I('"none"'))
next
}

View File

@ -420,7 +420,7 @@ labeller <- function(..., .rows = NULL, .cols = NULL,
keep.as.numeric = deprecated(), .multi_line = TRUE,
.default = label_value) {
if (lifecycle::is_present(keep.as.numeric)) {
lifecycle::deprecate_warn("2.0.0", "labeller(keep.as.numeric)")
deprecate_warn0("2.0.0", "labeller(keep.as.numeric)")
}
dots <- list2(...)
.default <- as_labeller(.default)

View File

@ -75,6 +75,7 @@ layer <- function(geom = NULL, stat = NULL,
inherit.aes = TRUE, check.aes = TRUE, check.param = TRUE,
show.legend = NA, key_glyph = NULL, layer_class = Layer) {
call_env <- caller_env()
user_env <- caller_env(2)
if (is.null(geom))
cli::cli_abort("Can't create layer without a geom.", call = call_env)
if (is.null(stat))
@ -84,7 +85,7 @@ layer <- function(geom = NULL, stat = NULL,
# Handle show_guide/show.legend
if (!is.null(params$show_guide)) {
lifecycle::deprecate_warn("2.0.0", "layer(show_guide)", "layer(show.legend)")
deprecate_warn0("2.0.0", "layer(show_guide)", "layer(show.legend)", user_env = user_env)
show.legend <- params$show_guide
params$show_guide <- NULL
}
@ -129,7 +130,7 @@ layer <- function(geom = NULL, stat = NULL,
if (geom$rename_size && "size" %in% extra_param && !"linewidth" %in% mapped_aesthetics(mapping)) {
aes_params <- c(aes_params, params["size"])
extra_param <- setdiff(extra_param, "size")
lifecycle::deprecate_warn("3.4.0", I("Using `size` aesthetic for lines"), I("`linewidth`"))
deprecate_soft0("3.4.0", I("Using `size` aesthetic for lines"), I("`linewidth`"), user_env = user_env)
}
if (check.param && length(extra_param) > 0) {
cli::cli_warn("Ignoring unknown parameters: {.arg {extra_param}}", call = call_env)
@ -142,7 +143,7 @@ layer <- function(geom = NULL, stat = NULL,
# Take care of size->linewidth aes renaming
if (geom$rename_size && "size" %in% extra_aes && !"linewidth" %in% mapped_aesthetics(mapping)) {
extra_aes <- setdiff(extra_aes, "size")
lifecycle::deprecate_warn("3.4.0", I("Using `size` aesthetic for lines"), I("`linewidth`"))
deprecate_soft0("3.4.0", I("Using `size` aesthetic for lines"), I("`linewidth`"), user_env = user_env)
}
if (check.aes && length(extra_aes) > 0) {
cli::cli_warn("Ignoring unknown aesthetics: {.field {extra_aes}}", call = call_env)
@ -171,7 +172,9 @@ layer <- function(geom = NULL, stat = NULL,
validate_mapping <- function(mapping, call = caller_env()) {
if (!inherits(mapping, "uneval")) {
msg <- paste0("{.arg mapping} must be created by {.fn aes}")
if (inherits(mapping, "ggplot")) {
# Native pipe have higher precedence than + so any type of gg object can be
# expected here, not just ggplot
if (inherits(mapping, "gg")) {
msg <- c(msg, "i" = "Did you use {.code %>%} or {.code |>} instead of {.code +}?")
}
@ -239,7 +242,7 @@ Layer <- ggproto("Layer", NULL,
!"linewidth" %in% names(self$computed_mapping) &&
"linewidth" %in% self$geom$aesthetics()) {
self$computed_mapping$size <- plot$mapping$size
lifecycle::deprecate_warn("3.4.0", I("Using `size` aesthetic for lines"), I("`linewidth`"))
deprecate_soft0("3.4.0", I("Using `size` aesthetic for lines"), I("`linewidth`"))
}
# defaults() strips class, but it needs to be preserved for now
class(self$computed_mapping) <- "uneval"

View File

@ -302,6 +302,8 @@ scale_apply <- function(data, vars, method, scale_id, scales) {
pieces <- lapply(seq_along(scales), function(i) {
scales[[i]][[method]](data[[var]][scale_index[[i]]])
})
# Remove empty vectors to avoid coercion issues with vctrs
pieces[lengths(pieces) == 0] <- NULL
o <- order(unlist(scale_index))[seq_len(sum(lengths(pieces)))]
vec_c(!!!pieces)[o]
})

View File

@ -198,7 +198,7 @@ draw_key_linerange <- function(data, params, size) {
draw_key_pointrange <- function(data, params, size) {
grobTree(
draw_key_linerange(data, params, size),
draw_key_point(transform(data, params, size = (data$size %||% 1.5) * 4))
draw_key_point(transform(data, size = (data$size %||% 1.5) * 4), params)
)
}

View File

@ -21,6 +21,9 @@
#' @keywords internal
#' @export
ggplot_build <- function(plot) {
# Attaching the plot env to be fetched by deprecations etc.
attach_plot_env(plot$plot_env)
UseMethod('ggplot_build')
}
@ -150,6 +153,9 @@ layer_grob <- function(plot, i = 1L) {
#' @param data plot data generated by [ggplot_build()]
#' @export
ggplot_gtable <- function(data) {
# Attaching the plot env to be fetched by deprecations etc.
attach_plot_env(data$plot$plot_env)
UseMethod('ggplot_gtable')
}

View File

@ -210,7 +210,7 @@ PositionStack <- ggproto("PositionStack", Position,
)
}
data <- vec_rbind(neg, pos)[match(seq_len(nrow(data)), c(which(negative), which(!negative))),]
data <- vec_rbind0(neg, pos)[match(seq_len(nrow(data)), c(which(negative), which(!negative))),]
flip_data(data, params$flipped_aes)
}
)

View File

@ -62,12 +62,12 @@ qplot <- function(x, y, ..., data, facets = NULL, margins = FALSE,
xlab = NULL, ylab = NULL,
asp = NA, stat = deprecated(), position = deprecated()) {
lifecycle::deprecate_warn("3.4.0", "qplot()")
deprecate_soft0("3.4.0", "qplot()")
caller_env <- parent.frame()
if (lifecycle::is_present(stat)) lifecycle::deprecate_stop("3.4.0", "qplot(stat)")
if (lifecycle::is_present(position)) lifecycle::deprecate_stop("3.4.0", "qplot(position)")
if (lifecycle::is_present(stat)) lifecycle::deprecate_stop("2.0.0", "qplot(stat)")
if (lifecycle::is_present(position)) lifecycle::deprecate_stop("2.0.0", "qplot(position)")
if (!is.character(geom)) {
cli::cli_abort("{.arg geom} must be a character vector")
}

View File

@ -22,7 +22,7 @@ reshape_add_margins <- function(df, vars, margins = TRUE) {
df
})
vec_rbind(!!!margin_dfs)
vec_rbind0(!!!margin_dfs)
}
reshape_margins <- function(vars, margins = NULL) {

View File

@ -560,6 +560,17 @@ check_breaks_labels <- function(breaks, labels) {
TRUE
}
default_transform <- function(self, x) {
new_x <- self$trans$transform(x)
axis <- if ("x" %in% self$aesthetics) "x" else "y"
check_transformation(x, new_x, self$scale_name, axis)
new_x
}
has_default_transform <- function(scale) {
transform_method <- environment(scale$transform)$f
identical(default_transform, transform_method) || identical(identity, transform_method)
}
#' @rdname ggplot2-ggproto
#' @format NULL
@ -589,12 +600,7 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
!has_data && !has_limits
},
transform = function(self, x) {
new_x <- self$trans$transform(x)
axis <- if ("x" %in% self$aesthetics) "x" else "y"
check_transformation(x, new_x, self$scale_name, axis)
new_x
},
transform = default_transform,
map = function(self, x, limits = self$get_limits()) {
x <- self$rescale(self$oob(x, range = limits), limits)
@ -637,7 +643,11 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
# Ensure limits don't exceed domain (#980)
domain <- suppressWarnings(self$trans$transform(self$trans$domain))
limits <- oob_squish(limits, sort(domain))
domain <- sort(domain)
# To avoid NaN causing issues. NaN are dropped by the sort()
if (length(domain) == 2) {
limits <- oob_squish(limits, domain)
}
# Limits in transformed space need to be converted back to data space
limits <- self$trans$inverse(limits)
@ -819,9 +829,7 @@ ScaleDiscrete <- ggproto("ScaleDiscrete", Scale,
self$range$train(x, drop = self$drop, na.rm = !self$na.translate)
},
transform = function(x) {
x
},
transform = identity,
map = function(self, x, limits = self$get_limits()) {
n <- sum(!is.na(limits))
@ -1001,12 +1009,7 @@ ScaleBinned <- ggproto("ScaleBinned", Scale,
self$range$train(x)
},
transform = function(self, x) {
new_x <- self$trans$transform(x)
axis <- if ("x" %in% self$aesthetics) "x" else "y"
check_transformation(x, new_x, self$scale_name, axis)
new_x
},
transform = default_transform,
map = function(self, x, limits = self$get_limits()) {
if (self$after.stat) {

View File

@ -141,96 +141,73 @@ ScaleDiscretePosition <- ggproto("ScaleDiscretePosition", ScaleDiscrete,
}
)
# Can't use vctrs - vctrs is too restrictive for mapped_discrete
new_mapped_discrete <- function(x = double()) {
vec_assert(x, double())
obj <- new_vctr(x, class = "ggplot2_mapped_discrete")
# vctrs does not support inheriting from numeric base class
class(obj) <- c(class(obj), "numeric")
obj
# Check the storage mode is double but don't error on additional attributes
vec_assert(as.vector(x), double())
class(x) <- c("mapped_discrete", "numeric")
x
}
mapped_discrete <- function(x = double()) {
if (is.null(x)) return(NULL)
if (is.array(x)) x <- as.vector(x)
new_mapped_discrete(vec_cast(x, double()))
}
is_mapped_discrete <- function(x) inherits(x, "ggplot2_mapped_discrete")
is_mapped_discrete <- function(x) inherits(x, "mapped_discrete")
#' @export
format.ggplot2_mapped_discrete <- function(x, ...) format(vec_data(x), ...)
#' @export
vec_ptype2.ggplot2_mapped_discrete.ggplot2_mapped_discrete <- function(x, y, ...) new_mapped_discrete()
#' @export
vec_ptype2.ggplot2_mapped_discrete.double <- function(x, y, ...) new_mapped_discrete()
#' @export
vec_ptype2.double.ggplot2_mapped_discrete <- function(x, y, ...) new_mapped_discrete()
#' @export
vec_ptype2.ggplot2_mapped_discrete.integer <- function(x, y, ...) new_mapped_discrete()
#' @export
vec_ptype2.integer.ggplot2_mapped_discrete <- function(x, y, ...) new_mapped_discrete()
#' @export
vec_ptype2.ggplot2_mapped_discrete.character <- function(x, y, ...) character()
#' @export
vec_ptype2.character.ggplot2_mapped_discrete <- function(x, y, ...) character()
#' @export
vec_ptype2.ggplot2_mapped_discrete.factor <- function(x, y, ...) new_mapped_discrete()
#' @export
vec_ptype2.factor.ggplot2_mapped_discrete <- function(x, y, ...) new_mapped_discrete()
#' @export
vec_cast.ggplot2_mapped_discrete.ggplot2_mapped_discrete <- function(x, to, ...) x
#' @export
vec_cast.ggplot2_mapped_discrete.integer <- function(x, to, ...) mapped_discrete(x)
#' @export
vec_cast.integer.ggplot2_mapped_discrete <- function(x, to, ...) as.integer(vec_data(x))
#' @export
vec_cast.ggplot2_mapped_discrete.double <- function(x, to, ...) new_mapped_discrete(x)
#' @export
vec_cast.double.ggplot2_mapped_discrete <- function(x, to, ...) vec_data(x)
#' @export
vec_cast.character.ggplot2_mapped_discrete <- function(x, to, ...) as.character(vec_data(x))
#' @export
vec_cast.ggplot2_mapped_discrete.factor <- function(<