我在 R 中运行 PCA 并使用 fviz
绘制结果来自 Factoextra
的函数包裹。我想使用此代码更改标题和值等图例属性
acp<-PCA(params_alpha, scale.unit = TRUE, ncp=5, quali.sup=c(1,2))
plot1<-fviz_pca_biplot(acp, geom=c("point"), pointsize=1, col.var="black", axes=c(1,2), habillage=2)+
theme(legend.text = element_text("Lobulo"))
我在这里有两个主要问题:首先,当我运行代码时,出现此错误:
In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font family not found in Windows font database
我试图用这篇文章解决它Can't change fonts in ggplot/geom_text但它没有效果。这段代码的另一个问题是图例属性根本没有改变。
我只想更改图例标题和值,但我不知道如何更改。如果你能帮助我,我将不胜感激。
最佳答案
我一直在研究,可以找到解决问题的方法。这是我使用的代码
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"))
我还进行了一些更改以调整点的形状和颜色。我希望它对其他人有用。
这个链接也很有用https://rstudio-pubs-static.s3.amazonaws.com/323416_ab58ad22d9e64ba2831569cf3d14a609.html
关于r - 从 Factoextra 更改 fviz 函数中的图例属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58070623/