Jor*_*uiz 6 visualization r ggplot2 pca
fviz我正在 R 中运行 PCA 并使用包中的函数 绘制结果Factoextra。我想使用此代码更改标题和值等图例属性
acp<-PCA(params_alpha, scale.unit = TRUE, ncp=5, quali.sup=c(1,2))\n\n plot1<-fviz_pca_biplot(acp, geom=c("point"), pointsize=1, col.var="black", axes=c(1,2), habillage=2)+\n theme(legend.text = element_text("Lobulo"))\nRun Code Online (Sandbox Code Playgroud)\n\n我这里有两个主要问题:首先,当我运行代码时出现此错误:
\n\n In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font family not found in Windows font database \nRun Code Online (Sandbox Code Playgroud)\n\n我尝试使用这篇文章Can't Change fonts in ggplot/geom_text来解决它,但它没有效果。这段代码的另一个问题是图例属性根本没有改变。
我只想更改图例标题和值,但我不知道如何更改。如果您能帮助我,我\xc2\xb4d将非常感激。
\n我不断研究并找到了问题的解决方案。这是我使用的代码
plot1<-fviz_pca_biplot(acp, geom.ind="point", pointsize=1, col.var="black", axes=c(1,2), col.ind=params_alpha$lob ,pointshape=19) +
scale_color_manual(name = "Lobulo", labels = c("Frontal", "Occipital", "Parietal", "Temporal"),
values= c("red","blue","orange","forestgreen"))
Run Code Online (Sandbox Code Playgroud)
我还做了一些更改以调整点的形状和颜色。我希望它对其他人有用。
此链接也很有用https://rstudio-pubs-static.s3.amazonaws.com/323416_ab58ad22d9e64ba2831569cf3d14a609.html