Skip to content

Layers have names #5967

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

Merged
merged 10 commits into from
Aug 26, 2024
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
simplify special key_glyph case
  • Loading branch information
teunbrand committed Jul 1, 2024
commit aa30217f10a9c80c77a58f727e24c883cc0ca01d
12 changes: 3 additions & 9 deletions R/layer.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,6 @@ layer <- function(geom = NULL, stat = NULL,
position <- check_subclass(position, "Position", env = parent.frame(), call = call_env)

# Special case for na.rm parameter needed by all layers

# Special case for key_glyph parameter which is handed in through
# params since all geoms/stats forward ... to params
if (!is.null(params$key_glyph)) {
key_glyph <- params$key_glyph
params$key_glyph <- NULL # remove to avoid warning about unknown parameter
}
params$na.rm <- params$na.rm %||% FALSE

# Split up params between aesthetics, geom, and stat
Expand All @@ -143,7 +136,8 @@ layer <- function(geom = NULL, stat = NULL,
geom_params <- params[intersect(names(params), geom$parameters(TRUE))]
stat_params <- params[intersect(names(params), stat$parameters(TRUE))]

all <- c(geom$parameters(TRUE), stat$parameters(TRUE), geom$aesthetics())
ignore <- "key_glyph"
all <- c(geom$parameters(TRUE), stat$parameters(TRUE), geom$aesthetics(), ignore)

# Take care of plain patterns provided as aesthetic
pattern <- vapply(aes_params, is_pattern, logical(1))
Expand Down Expand Up @@ -177,7 +171,7 @@ layer <- function(geom = NULL, stat = NULL,
}

# adjust the legend draw key if requested
geom <- set_draw_key(geom, key_glyph)
geom <- set_draw_key(geom, key_glyph %||% params$key_glyph)

fr_call <- layer_class$constructor %||% frame_call(call_env)

Expand Down