如果要设置alpha
为特定值,则必须将其设置为aes以外的参数,例如geom_point(alpha = foo$alpha)
或使用scale_alpha_identity
。尝试这个:
foo <- data.frame(x=seq(1:10))
foo$y <- foo$x
foo$alpha <- c(rep(1, 7), rep(0.5, 3))
library(ggplot2)
ggplot(foo, aes(x, y)) +
geom_point(aes(alpha=alpha)) +
scale_alpha_identity()
foo$alpha <- c(rep(1, 7), rep(0.1, 3))
ggplot(foo, aes(x, y)) +
geom_point(aes(alpha=alpha)) +
scale_alpha_identity()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句