我已经删除了ggplot2
文档,Stack和ggplot2
Google网上论坛电子邮件列表 - 但无济于事。
请有人告诉我如何合并alpha
(不透明度)和size
的图例?它们的标题是"(1-val2)"和" val2"分别。
通常将alpha和size映射到val2会自动合并轴。但是因为我正在使用" val2"和" 1-val2",这不会发生。我曾与scale_size_continuous
和scale_alpha_continuous
玩过,但没有成功。
这是一个MWE:
require(ggplot2)
dummy <- data.frame(x=c(runif(12,5,10)),
y=c(runif(12,5,10)),
val1=c("a","b","c","a","b","c","a","b","c","a","b","c"),
val2=c(0.4,0.6,0.7,0.2,0.8,0.6,0.7,0.2,0.5,0.8,0.4,0.7))
p <- ggplot() +
geom_point(data=dummy, aes(x=x, y=y,color=val1, size=val2, alpha=(1-val2)))
答案 0 :(得分:2)
使用range
的{{1}}参数反转比例:
scale_alpha_continuous
答案 1 :(得分:2)
trans
参数在这里也可能有用:
ggplot() +
geom_point(data=dummy, aes(x = x, y = y, color = val1, size = val2, alpha = val2)) +
scale_alpha_continuous(trans = "reverse")
trans
和?scale_alpha_continuous
中的?continuous_scale
参数说明非常简短。但是,您可以找到一些示例here。