Setting the label and value size for axis in PCA plot with fviz_pca_ind in factoextra
1
0
Entering edit mode
6.7 years ago
lessismore ★ 1.4k

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 • 17k views
ADD COMMENT
3
Entering edit mode
6.7 years ago

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

ADD COMMENT
0
Entering edit mode

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

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

ADD REPLY
1
Entering edit mode

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.

ADD REPLY
1
Entering edit mode

Very clear! thanks a lot

ADD REPLY
0
Entering edit mode

De nada - nos vemos

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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')
ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1579 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6