Skip to content

Commit d0393ae

Browse files
committed
drop empty aesthetics with warning
1 parent c679d43 commit d0393ae

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

R/layer.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ layer <- function(geom = NULL, stat = NULL,
152152
if (any(pattern)) {
153153
aes_params[pattern] <- lapply(aes_params[pattern], list)
154154
}
155+
# Drop empty aesthetics
156+
empty_aes <- names(aes_params)[lengths(aes_params) == 0]
157+
if (length(empty_aes) > 0) {
158+
cli::cli_warn(
159+
"Ignoring empty aesthetic{?s}: {.arg {empty_aes}}.",
160+
call = call_env
161+
)
162+
aes_params <- aes_params[setdiff(names(aes_params), empty_aes)]
163+
}
155164

156165
# Warn about extra params and aesthetics
157166
extra_param <- setdiff(names(params), all)

0 commit comments

Comments
 (0)