gpt4 book ai didi

r - ggbiplot - 改变点的大小

转载 作者:行者123 更新时间:2023-12-04 19:59:00 27 4
gpt4 key购买 nike

有人知道如何更改点大小并仍然保持下面代码中的组颜色吗?

只需添加 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com