Search code examples
rpca

How to change the y label of contributions of column elements plot in factoextra package


When I use fviz_contrib to plot contributions of column elements in factoextra package, the default y label is Contributions (%), I wonder how can I change to other text.

I used the following codes:

library(factoextra)
library(FactoMineR)
# Principal component analysis
# ++++++++++++++++++++++++++
data(decathlon2)
decathlon2.active <- decathlon2[1:23, 1:10]
res.pca <- prcomp(decathlon2.active,  scale = TRUE)

# variable contributions on axis 1
fviz_contrib(res.pca, choice="var", axes = 1, top = 10, ylab = 'my label y' )

However, it prompted me

Error in ggpubr::ggbarplot(df, x = "name", y = "contrib", fill = fill, : formal argument "ylab" matched by multiple actual arguments

How to solve this?

Thanks.


Solution

  • You can use the following code for that

    # variable contributions on axis 1
    library(ggpubr)
    p <- fviz_contrib(res.pca, choice="var", axes = 1, top = 10) 
    ggpar(p, ylab = 'my label y') 
    

    enter image description here