如何在不显示图例的情况下使用 fviz_pca_ind() 绘图?

How to plot with fviz_pca_ind() without showing the legend?

我想让图例消失。以上是我在 R 中对鸢尾花数据集所做的示例。 我在 fviz_pca_ind() 的文档中找不到省略图例的变量。

library(factoextra)
library(FactoMineR)
pca_iris <- PCA(iris[ ,-5])
iris$species <- as.factor(iris$Species)
pca_n.macros_plot <- fviz_pca_ind(pca_iris, 
             pointshape = 21,habillage = iris$species,
             palette = "jco",label="none",
             geom.ind = c("point"),geom = c("point"),
             title="PCA iris")

根据 fviz_pca 的 documentation

输出 class 是 ggggplot。因此,以下代码应该适合您。

pca_n.macros_plot + theme(legend.position = "none")