您有一个包含多个组的散点图(例如,10个)。你为这些组画出了95%的置信度椭圆。
问题:你不需要看到所有组的置信椭圆(因为不是必须的,或者因为他们中的一些点很少,导致巨大的椭圆)
问:如何在保留散点图上的点的同时删除已确定组的置信椭圆?
示例:在此代码中,您希望删除versicolor的可信椭圆,但保留点的颜色,并保留其他椭圆
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_point() +
stat_ellipse(aes(color = Species)) +
theme(legend.position = "bottom")
发布于 2019-11-29 14:47:47
Z.lin的答案中的图例并不准确,因为即使没有绘制椭圆,杂色仍然有一条线穿过形状。我们可以通过指定aes(线型=种)和scale_linetype_manual来绕过它。
library(dplyr, ggplot2)
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_point(aes(shape = Species)) +
stat_ellipse(aes(linetype = Species)) +
scale_linetype_manual(values = c(1,0,1)) +
theme(legend.position = "bottom")
[
]
https://stackoverflow.com/questions/58234376
复制相似问题