Skip to content

Commit b341653

Browse files
committed
positions communicate their aesthetics
1 parent fe7abd1 commit b341653

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

R/layer.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ layer <- function(geom = NULL, stat = NULL,
134134

135135
# Split up params between aesthetics, geom, and stat
136136
params <- rename_aes(params)
137-
aes_params <- params[intersect(names(params), geom$aesthetics())]
137+
aes_params <- params[intersect(names(params), union(geom$aesthetics(), position$aesthetics()))]
138138
geom_params <- params[intersect(names(params), geom$parameters(TRUE))]
139139
stat_params <- params[intersect(names(params), stat$parameters(TRUE))]
140140

141141
ignore <- c("key_glyph", "name")
142-
all <- c(geom$parameters(TRUE), stat$parameters(TRUE), geom$aesthetics(), ignore)
142+
all <- c(geom$parameters(TRUE), stat$parameters(TRUE), geom$aesthetics(), position$aesthetics(), ignore)
143143

144144
# Take care of plain patterns provided as aesthetic
145145
pattern <- vapply(aes_params, is_pattern, logical(1))
@@ -170,7 +170,7 @@ layer <- function(geom = NULL, stat = NULL,
170170

171171
extra_aes <- setdiff(
172172
mapped_aesthetics(mapping),
173-
c(geom$aesthetics(), stat$aesthetics())
173+
c(geom$aesthetics(), stat$aesthetics(), position$aesthetics())
174174
)
175175
# Take care of size->linewidth aes renaming
176176
if (geom$rename_size && "size" %in% extra_aes && !"linewidth" %in% mapped_aesthetics(mapping)) {

R/position-.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ Position <- ggproto("Position",
6868

6969
compute_panel = function(self, data, params, scales) {
7070
cli::cli_abort("Not implemented.")
71+
},
72+
73+
aesthetics = function(self) {
74+
required_aes <- self$required_aes
75+
if (!is.null(required_aes)) {
76+
required_aes <- unlist(strsplit(self$required_aes, "|", fixed = TRUE))
77+
}
78+
c(union(required_aes, names(self$default_aes)))
7179
}
7280
)
7381

0 commit comments

Comments
 (0)