ggplot2:如何用geom_jitter和geom_point控制点颜色? [英] ggplot2: How do you control point color with geom_jitter and geom_point?
问题描述
这与此处。然而,我并没有试图制作 boxplot ,而是ggplot2中的 scatterplot ,但添加了参数 geom_jitter()
添加黑点,这似乎与我的数据集无关。
以下是使用mpg数据包的示例:
这是一个<
$ b
gmpg <-ggplot(data = mpg, aes(x = hwy,y = cty))
gmpg + geom_point(aes(col = manufacturer))
产生这种结果:
$ b $ p现在,如果我添加抖动参数,这就是发生了什么
gmpg + geom_point(aes(col = manufacturer))+ geom_jitter()
我试过减少alpha等。,但黑点仍然存在。这些东西到底是什么?如何去除它们?
不需要在 geom _ *
功能。这应该有效:
gmpg < - ggplot(data = mpg,aes(x = hwy,y = cty,col = )
gmpg + geom_point()+ geom_jitter()
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.
Here's an example using the mpg data pack:
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
gmpg+geom_point(aes(col=manufacturer))+geom_jitter()
I've tried reducing the alpha etc., but the black dots remain. 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. This should work:
gmpg <- ggplot(data=mpg, aes(x=hwy, y=cty, col=manufacturer))
gmpg + geom_point() + geom_jitter()
这篇关于ggplot2:如何用geom_jitter和geom_point控制点颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!