lro*_*oca 3 r ggplot2 ggbiplot
有人知道如何更改点大小并仍然在下面的代码中保持组颜色?
只需将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)
Run Code Online (Sandbox Code Playgroud)
在内部添加颜色美感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')
Run Code Online (Sandbox Code Playgroud)