在这个例子中,ggbiplot脚本图有3组,我如何改变标记颜色和形状?
library(ggbiplot)
data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, group=wine.class,
varname.size = 3, labels.size=3,
ellipse = TRUE, circle = TRUE) +
scale_color_discrete(name = '') +
geom_point(aes(colour=wine.class), size = 3) +
theme(legend.direction ='horizontal',
legend.position = 'top')发布于 2016-10-28 12:47:30
下面这些对我来说很有用。
ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, group=wine.class,
varname.size = 3, labels.size=3, ellipse = TRUE, circle = TRUE) +
scale_color_manual(name="Variety", values=c("orange", "purple", "green")) +
scale_shape_manual(name="Variety", values=c(17:19)) +
geom_point(aes(colour=wine.class, shape=wine.class), size = 3) +
theme(legend.direction ="horizontal",
legend.position = "top")

对于传说来说,诀窍似乎是将相同的name用于scale_color_manual和scale_shape_manual。
https://stackoverflow.com/questions/40287943
复制相似问题