本文介绍了ggplot2:如何用geom_jitter和geom_point控制点颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 这与此处。然而,我并没有试图制作 boxplot ,而是ggplot2中的 scatterplot ,但添加了参数 geom_jitter()添加黑点,这似乎与我的数据集无关。 以下是使用mpg数据包的示例: 这是一个 $ b gmpg gmpg + geom_point(aes(col = manufacturer)) 产生这种结果: $ b $ p现在,如果我添加抖动参数,这就是发生了什么 gmpg + geom_point(aes(col = manufacturer))+ geom_jitter() 我试过减少alpha等。,但黑点仍然存在。这些东西到底是什么?如何去除它们? 解决方案 不需要在 geom _ * 功能。这应该有效: gmpg 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 happensgmpg+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控制点颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-29 03:57