Closed
Description
I am highlighting some points by a combination of stage()
and after_scale()
.
I found that after_scale
can find aesthetic variables, but not variables in the original data.
It is fine, if that's a design.
As a workaround, I let after_scale
find the variable in the data by mapping it to an aesthetic variable.
It works in some case, but not always.
As far as I tried, it seems the error is related to discrete variables.
library(ggplot2)
g <- ggplot(mtcars) +
aes(wt, mpg, highlight = am == 1) +
geom_point(
aes(colour = stage(cyl, after_scale = ifelse(highlight, colour, 'gray'))),
shape = 21
)
# Okay
g
# Okay
g + aes(fill = am)
# Error
g + aes(fill = as.factor(am))
#> Error in ifelse(highlight, colour, "gray"): object 'highlight' not found
# Error
ggplot(iris) +
aes(Sepal.Length, Sepal.Width, highlight = Species == "setosa") +
geom_point(
aes(
colour = stage(
Species, after_scale = ifelse(highlight, colour, 'gray')
)
)
)
#> Error in ifelse(highlight, colour, "gray"): object 'highlight' not found
Created on 2020-01-13 by the reprex package (v0.3.0.9001)
Metadata
Metadata
Assignees
Labels
No labels