ggbiplot-更改点大小 [英] ggbiplot - change the point size
本文介绍了ggbiplot-更改点大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人在下面的代码中有一个想法如何更改点的大小并仍然保持组的颜色吗?
Does someone have an idea how to change the point size and still maintain the group colors in the code below?
只需添加geom_point(size = 8)
即可将所有点的颜色更改为黑色.
Just adding the geom_point(size = 8)
changes the colors of all the points to black.
代码:
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
,因此我将opts
更改为theme
.
Adding a color aesthetic inside geom_point
will keep the points colored by group. Also, I changed opts
to theme
, since opts
has been deprecated.
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')
这篇关于ggbiplot-更改点大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文