How to format PCA plot

Hi all,
I am working on PCA analysis and am wondering how to format the figure? For example, I use the code below to plot the figure, as shown below. How to edit the x and y axis titles? For example, I want x-axis to be PC1 instead of Dim1 (41.%), how to realize this? Second, how to remove the background grids and use a rectangular box? Thanks for your help.


# It contains 27 individuals (athletes) described by 13 variables. <- decathlon2[1:23, 1:10]
head([, 1:6], 4)

res.pca <- PCA(, graph = FALSE)

fviz_eig(res.pca, addlabels = TRUE, ylim = c(0, 50))

# plot the variables
fviz_pca_var(res.pca, col.var = "black")

I have another question regarding to this problem.
If I use the code below to create a PCA plot of PC3~PC4, and get the figure. How to put the two figures in one panel in R directly? Thanks again.

fviz_pca_var(res.pca, col.var = "black",axes=c(3,4))

Since it is a ggplot you can add features such as axis labels and theme elements. Try this code

plot1 <- fviz_pca_var(res.pca, col.var = "black")
plot1 + xlab("PC1") + ylab("PC2") +
   theme_bw() + theme(panel.grid.major = element_line(linetype = "blank"))

Thanks, it works. How to plot the loadings of each variable in PC1, PC2, etc? Thanks.

there is a biplot function and others - see the examples at fviz_pca: Quick Principal Component Analysis data visualization - R software and data mining - Easy Guides - Wiki - STHDA

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.