This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Setting the label and value size for axis in PCA plot with fviz_pca_ind in factoextra

Dear all,

im using fviz_pca_ind function in factoextra R package.

What i cannot accomplish is to set the size of the axis labels and values + the size of the legend

fviz_pca_ind(mydata.pca, repel = TRUE, alpha.ind = 1,
+              habillage = mydata_attributes$attribute1, # color by groups
+              palette = c("#00AFBB", "#E7B800"),labelsize = 5, pointsize = 1, font.family = "Arial",
+              addEllipses = TRUE # Concentration ellipse
+ )

i just found how to set the size of my samples and the points. Could somebody help me?

thank you in advance

r pca factoextra

1 answer

Make use of the ggtheme parameter that can be passed to the fviz functions. Specifically try this as a parameter:

frizz_pca_ind(...,
  ggtheme = theme(
    axis.text = element_text(size = 10),
    axis.title = element_text(size = 16, face  = 'bold')),
  ...)

Also take a look at the other theme functions. For example, for legend, use parameters like legend.title and legend.text

Take a further look here as an example: Boxplot in ggplot2

There is a page here briefly describing this: http://www.sthda.com/english/rpkgs/factoextra/reference/fviz_pca.html

fviz is just a wrapper for ggplot2, so, all functions should be compatible.

Kevin

Kevin you're always crucial. Could you explain what you said?

fviz is just a wrapper for ggplot2, so, all functions should be compatible

The fviz functions, as far as I understand, just use ggplot2 code 'behind the scenes', as we say in English. In particular, ggplot2 themes can be used via the ggtheme parameter of fviz.

Very clear! thanks a lot

Hi Kevin, In the same direction of the original question. I'm trying so hard to change the text label's color. I only manage define the color of individual but by so, it changes the label's color too. Could you help me with setting this up through ggtheme?

I really appreciate any help. Thank a lot

Hey Christian, which label do you mean? - it can be x- or y-axis labels, x- or y-axis title labels, point labels, legend labels, etc.

If x-axis title, it would be, for example:

axis.title.x = element_text(colour = 'forestgreen')

This would change axis tick values:

axis.text.x = element_text(color = 'gold')

Thanks for your reply. Sorry, I wans't clear enough. I meant the the point labels.

Kevin Blighe I sort of manage to add another coloring pallet to my individual point. Following this link. But either so, I rather prefer to fix the points color to "purple" and set the point's label color in different grey scale.

Have you tried to use the colour parameter of geom_text() or geom_label()?

Log in to answer this question.