我正在制作两个变量的散点图,并希望通过因子变量对点进行着色。这是一些可重现的代码:
data <- iris
plot(data$Sepal.Length, data$Sepal.Width, col=data$Species)
这一切都很好,但我怎么知道什么因素被着色成什么颜色?
data<-iris
plot(data$Sepal.Length, data$Sepal.Width, col=data$Species)
legend(7,4.3,unique(data$Species),col=1:length(data$Species),pch=1)
应该为你做。但是我更喜欢ggplot2
并建议在 R 中获得更好的图形。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)