有人知道如何更改点大小并仍然保持下面代码中的组颜色吗?
只需添加 geom_point(size = 8)
即可将所有点的颜色更改为黑色。
代码:
library(ggbiplot)
data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
g <- ggbiplot(wine.pca, obs.scale = 1, var.scale = 1,
groups = wine.class, varname.size = 8, labels.size=10 , ellipse = TRUE, circle = TRUE)
g <- g + scale_color_discrete(name = '') #+ geom_point(size = 8)
g <- g + opts(legend.direction = 'horizontal',
legend.position = 'top')
print(g)
最佳答案
在 geom_point
中添加颜色美学将使点按组着色。另外,我将 opts
更改为 theme
,因为 opts
已被弃用。
ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, group=wine.class,
varname.size = 8, labels.size=10,
ellipse = TRUE, circle = TRUE) +
scale_color_discrete(name = '') +
geom_point(aes(colour=wine.class), size = 8) +
theme(legend.direction ='horizontal',
legend.position = 'top')
关于r - ggbiplot - 改变点的大小,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24101287/