rggplot2pca

Font style inside PCA Graph (and ggcorrplot)


I am trying to prepare an article for publication and I am having trouble getting a consistent font style in my PCA charts. I am using the fviz_pca_var function. The code I am using is

library(ggplot2)
library(FactoMineR)
library(factoextra)

irispca <- PCA(iris,quali.sup = 5)
fviz_pca_var(irispca, col.var = "black", ggtheme = theme_classic2(base_family = "Times"))

The resulting chart looks like this. The problem being the text inside the chart is Arial not Times

I also tried this

add_el <- theme_grey() +
+   theme(text = element_text(family = "Times"))

fviz_pca_var(irispca, col.var = "black", ggtheme = add_el)

and this

fviz_pca_var(irispca, col.var = "black") + theme(text = element_text(size = 14,  family = "Times"))

Even the Scree plot gives the same issue

fviz_eig(irispca, addlabels = TRUE, ylim = c(0, 30), font.family = "Times")

Any tips would be great.

enter image description here


Solution

  • library(ggplot2)
    library(FactoMineR)
    library(factoextra)
    
    irispca <- PCA(iris,quali.sup = 5)
    

    Here is the solution. I can't post the plot due to the low repuration on Stackoverflow.

    fviz_pca_var(irispca, col.var = "black", font.family = "Times")
    

    Created on 2023-11-14 with reprex v2.0.2