I'm trying to use a fixed alpha aesthetic to manually highlight points in a plot. It fails when color is mapped to a factor.
library(ggplot2)
data(mtcars)
# fails (but should work)
ggplot(mtcars, aes(x=disp, y=hp, color=as.factor(cyl)))+geom_point(alpha=seq(0,1,length.out=32))
# Error: Aesthetics must be either length 1 or the same as the data (3): alpha
# fails (and should fail)
ggplot(mtcars, aes(x=disp, y=hp, color=as.factor(cyl)))+geom_point(alpha=seq(0,1,length.out=3))
# Error: Aesthetics must be either length 1 or the same as the data (32): alpha
# succeeds
ggplot(mtcars, aes(x=disp, y=hp, color=cyl))+geom_point(alpha=seq(0,1,length.out=32))