【发布时间】:2026-01-05 09:50:01
【问题描述】:
我想为特定的分类变量添加颜色。例如,我想特别突出(通过添加颜色)setosa 物种;对于其他物种(如弗吉尼亚和杂色),只有黑点。我想应该有一个简单的方法来做到这一点。我对 R 很陌生。
data(iris)
library(ggplot2)
#This is not desirable
ggplot(iris, aes(Sepal.Length, Petal.Width)) + geom_point() + geom_point(aes(colour=Species))
#This is what I aim to achieve, but it is not working
ggplot(iris, aes(Sepal.Length, Petal.Width)) + geom_point() + geom_point(aes(colour=Species$setosa))
【问题讨论】:
-
你遇到过this question吗?
-
我建议在这里阅读此来源:cookbook-r.com/Graphs
-
非常感谢您的 cmets 和参考资料!