1

I'm doing a PCA with the fviz_pca_biplot and would like to remove the ID of my dots to make the PCA clearer. I would like to keep my vectors label.

What command should I use to remove the ID?

Here's my code and the result.

pca_biplot = fviz_pca_biplot(res.pca, repel = TRUE, max.overlaps=Inf,
               col.var = "#000000", # Variables color #colour of the lines
               #colour = Population, #sets the colour of the data to be determined by population
               axes = c(3, 4), # choose PCs to plot
               habillage = data$Population,
               col.ind = "#696969", #colour of points
               labels=NULL
               )

pca_biplot + 
  labs(title ="ACP", x = "CP3 (15,3%)", y = "CP4 (9,6%)") + 
  scale_color_manual(values = c("blue","red")) + 
  theme_minimal() 

I also wrote a more detailed legend, but I'm not able to remove the initial label. I plan on simply block it with a white square over it, but is there a way to only keep the legend I customized?

stefan
  • 90,330
  • 6
  • 25
  • 51
Ocean
  • 11
  • 2

1 Answers1

1

You can remove the labels for your dots by setting geom="point" which means to only plot with points (the default is geom = c("point", "text")).

Using a minimal reproducible example based on iris:

library(factoextra)

iris2 <- subset(iris, Species != "setosa")
res.pca <- prcomp(iris2[, -5], scale = TRUE)

pca_biplot <- fviz_pca_biplot(res.pca,
  repel = TRUE, max.overlaps = Inf,
  col.var = "#000000",
  axes = c(3, 4),
  habillage = iris2$Species,
  col.ind = "#696969",
  labels = NULL,
  geom = "point"
)

pca_biplot +
  labs(title = "ACP", x = "CP3 (15,3%)", y = "CP4 (9,6%)") +
  scale_color_manual(values = c("blue", "red")) +
  theme_minimal()

stefan
  • 90,330
  • 6
  • 25
  • 51