首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >更改Factoextra上的形状

更改Factoextra上的形状
EN

Stack Overflow用户
提问于 2021-04-24 00:21:00
回答 1查看 131关注 0票数 1

我是一个非常新的程序员,希望改变我的PCA Biplot的形状。我的PCA Biplot代码如下:

代码语言:javascript
复制
group <- c(rep("SHIME 1_Trt1", times=8), rep('SHIME 1_Trt2', times=6),
rep("SHIME 2_Trt1", times=8), rep('SHIME 2_Trt2', times=6),
rep("SHIME 3_Trt1", times=8), rep('SHIME 3_Trt2', times=6)) 

clusters <- c(rep("SCFA", times=3), rep("Organic acid", times=3), 
rep("Alcohols", times=3), rep('AA', times=2), rep('Ketone', times=1), rep('Lipid', times=1))

j_scale <- prcomp(j, center=TRUE, scale=TRUE)

fviz_pca_biplot(j_scale, repel=TRUE, pointsize=4, pointshape=21, col.var=factor(clusters),
 arrowsize=0.6, labelsize=4, 
palette=c("#00AFBB", "#00AFBB", "#E7B800", "#E7B800", "#FC4E07", "#FC4E07", "#FC4E08"),
geom='point', fill.ind=group, legend.title=list(fill='System',color='Categories')) +
ggpubr::color_palette("lancet") 

颜色是按我喜欢的方式排列的,但我希望Trts之间的形状不同。例如: shime1 trt 1=蓝色圆圈,shime 1 trt 2=蓝色sq,shime 2 trt 1=绿色圆圈,依此类推。

我试过了:

代码语言:javascript
复制
scale_shape_manual(values=c()), habillage=group

不提供与fill.ind相同的输出,并与col.var=、geom.ind/var和shape.ind发生冲突

更改pointshape=c()似乎也不起作用

甚至是修改后的代码:

代码语言:javascript
复制
fviz_pca_biplot(j_scale, repel=TRUE, pointsize=4, pointshape=21, col.ind=shimeb_pca$Type,
col.var='black',  arrowsize=0.6, labelsize=4, 
palette=c("#00AFBB", "#00AFBB", "#E7B800", "#E7B800", "#FC4E07", "#FC4E07", "#FC4E08"), 
geom='point', legend.title=list(fill='System')) + theme_minimal() + 
scale_shape_manual(values=c(5, 20, 21, 20, 21, 20))
#This looks worse than the original code

prcomp(j,center=TRUE,scale=TRUE)之前的数据摘录:

代码语言:javascript
复制
         Acetate Propionate  Butyrate   Lactate  Formate Succinate   Ethanol Methanol
S1_0    40.09358  10.726725 0.7180000 0.6104750 1.901075 0.5284000 10.730900 1.163525
S1_1    40.05890  10.962025 0.6841500 0.7253000 1.958825 0.7286250 11.013750 1.217125
S1_1.5  44.27740  13.020812 0.8308875 0.4131125 1.355225 0.0539250 10.897100 1.267700
S1_2    43.87610  11.580800 0.6531500 0.7476500 2.461150 0.7961250  9.628950 1.338500
S1_3    45.70235  12.458150 0.7131750 0.4026250 2.059375 0.5043250 20.098575 1.426900
S1_5    45.15580  12.711575 0.7775750 0.1914750 0.864700 0.0535750 10.404050 1.357200
S1_7    44.11000  12.885625 0.7210250 0.3525500 2.534225 0.0616750  7.744150 1.431675
S1_9    47.27562  12.739375 0.6837000 0.4053000 2.804775 0.0570500 13.701000 1.630200

任何帮助都是非常感谢的。提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2021-04-24 05:30:16

试试fviz_pca_biplot(j_scale, geom.ind = 'point', repel = TRUE, pointsize = 4, habillage = group, arrowsize = 0.6, labelsize = 4, legend.title = list(fill = 'System'))

做得好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67233602

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档