0



I would like to ask how can I combine plots generated by factoextra with plots generated by corrplot

I have plots as follows:

fviz_pca_var(pca1, col.var = "black")
fviz_eig(pca1, addlabels = TRUE, ylim = c(0, 50))

corrplot(pca1$var$cos2, is.corr=FALSE, title = "Quality of representation")
corrplot(pca1$var$contrib, is.corr=FALSE, title =" Variables countributions to each component")

I can combine only the 3rd and 4th plots using par(mfrow=c(2,2)), Not all plots. it returns an error message for fviz plots

I have tried ggpubr after assigning each of the plot codes above to a new object p1,p2,p3,p4...

ggpubr::ggarrange(p1,p2,p3,p4)


This ggpubr combines only the 1st and the 2nd plots "fviz" and not all plots. (the contrary to fist case)

My question: Is there any way to combine those two different sets of plots in one 2*2 plot??

Thanks in advance.

  • I think the issue is that you want to combine base plot plots (corrplot) and ggplots/grobs (factoextra). Maybe the package `ggplotify` can help. With the function `as.grob()` you can create a grob from a base plot. – ricoderks Jun 03 '20 at 08:49
  • You may want to check this out: https://stackoverflow.com/questions/14124373/combine-base-and-ggplot-graphics-in-r-figure-window – davidnortes Jun 03 '20 at 09:10

0 Answers0