[英]ggplot2: How do you control point color with geom_jitter and geom_point?
This is related to the question here . 这与此处的问题有关。 However, I'm not trying to make a boxplot , but a scatterplot in ggplot2 , but adding the argument
geom_jitter()
adds black dots which seem to be non-related to my dataset. 不过,我并不想做一个箱线图 ,但在GGPLOT2散点图 ,但增加的说法
geom_jitter()
增加了黑点 ,这似乎是不相关的,以我的数据集。
Here's an example using the mpg data pack : 以下是使用mpg数据包的示例 :
This is a simple scatterplot, that looks a bit "too clean" 这是一个简单的散点图,看起来有点“太干净”
gmpg<-ggplot(data=mpg, aes(x=hwy, y=cty))
gmpg+geom_point(aes(col=manufacturer))
Which produces this: 产生这个:
Now, if I add the argument jitter, this is what happens 现在,如果我添加参数jitter,就会发生这种情况
gmpg+geom_point(aes(col=manufacturer))+geom_jitter()
I've tried reducing the alpha etc., but the black dots remain. 我试过减少alpha等,但黑点仍然存在。 What on earth are these and how do I remove them?
究竟是什么,如何删除它们?
There is no need to assign a new aesthetic mapping in the geom_*
functions. 无需在
geom_*
函数中指定新的美学映射。 This should work: 这应该工作:
gmpg <- ggplot(data=mpg, aes(x=hwy, y=cty, col=manufacturer))
gmpg + geom_point() + geom_jitter()
不需要在其中添加geom_point(),geom_jitter()就足够了。
ggplot(mpg,aes(cty,hwy,color=manufacturer))+geom_jitter();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.