我在R中运行主成分分析,并使用Factoextra
包中的fviz
函数绘制结果。我想使用此代码更改图例属性,如标题和值
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来解决这个问题,但是没有效果。关于这段代码的另一个问题是图例属性根本没有改变。
我只想更改图例标题和值,但我不知道如何更改。如果你能帮助我,我将不胜感激。
发布于 2019-09-24 05:43:26
我一直在研究,并找到了解决问题的方法。这是我使用的代码
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
https://stackoverflow.com/questions/58070623
复制相似问题