Minyi Han
Minyi Han

Reputation: 827

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.

Upvotes: 2

Views: 669

Answers (1)

UseR10085
UseR10085

Reputation: 8166

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

Upvotes: 2

Related Questions