【发布时间】:2017-07-18 14:10:13
【问题描述】:
我正在尝试在 ggplot2 中使用 geom_point() 绘制一个图,该图具有映射到 x、y、颜色和形状的变量,并避开颜色而不是形状的位置。
x=tibble(Color=c(rep('A',12),rep('B',12),rep('C',12)),
Shape=rep(c(rep('A',3),rep('B',3),rep('C',3),rep('D',3)),3),
xVar=rep(c('A','B','C'),12),
Value=rnorm(36))
ggplot(x,aes(xVar,Value,color=Color,shape=Shape))+
geom_point(position=position_dodge(width=.5))
是否可以将闪避位置限制为仅一种美学?我搜索了文档和堆栈溢出,但还没有找到任何东西。
【问题讨论】:
-
ggplot(data=x) + geom_point(aes(xVar, Value, color=Color), position=position_dodge(width=.5)) + geom_point(aes(xVar,Value,shape=Shape))怎么样 -
我没有看到任何其他选择,只是按照 juan 的建议复制这些点。如何在一个位置有一个点的形状,而在另一个位置有颜色?
-
@PaulEndymion,无需重复。