Introduce NA
, and map those to the NA
color with scale_fill_discrete
:
ggplot(mtcars,aes(x=mpg,y=wt)) +
geom_point(size=10,
aes(
color=factor(cyl),
shape=factor(gear),
fill=factor(ifelse(vs, NA, cyl)) # <---- NOTE THIS
) ) +
scale_shape_manual(values=c(21,22,23)) +
scale_fill_discrete(na.value=NA, guide="none") # <---- NOTE THIS
Produces:
EDIT: To address Mr Flick, we can cheat and add layers / alpha. Note we need to add a layer because as far as I know there is no way to control alpha independently for color and fill:
library(ggplot2)
ggplot(mtcars,aes(x=mpg,y=wt, color=factor(cyl), shape=factor(gear))) +
geom_point(size=10, aes(fill=factor(cyl), alpha=as.character(vs))) +
geom_point(size=10) +
scale_shape_manual(values=c(21,22,23)) +
scale_alpha_manual(values=c("1"=0, "0"=1))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…