0

I'm trying to put the two axes of my biplot exactly equally scaled (i.e., 1 cm on the vertical axis must represent the same 1 cm on the horizontal axis). How can I do that with fviz_pca? or there is some better pca package?

My code

fviz_pca_ind(res.pca,
         col.ind = groups, # color by groups
         palette = c("#00AFBB",  "#FC4E07"),
         addEllipses = TRUE, # Concentration ellipses
         ellipse.type = "convex",
         legend.title = "Groups",
         repel = T, ggtheme=theme(axis.text=element_text(size=16), axis.title=element_text(size=16)))

PCA fviz_pca_ind

Maba
  • 93
  • 1
  • 3
  • 6
  • 1
    It will be much easier for folks to help you if you make this a [reproducible question](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). I'm not sure if it applies in this case, but `ggplot` has a `coord_equal` function for scaling axes in this way that you may be able to add to this object – camille Oct 01 '18 at 14:31
  • it worked! Thanks! – Maba Oct 01 '18 at 14:52

1 Answers1

0

As the fviz function works based on ggplot2 you just need to add the information of axis lenght at the end of the funtion like this:

fviz_pca_biplot(scaptotrigona.pca,[...]) +xlim(-1, 1) + ylim (-1, 1)

remember that the values inside the "xlim()" and "ylim()" mus be equals, if you use "xlim(-1, 5)" for example, it won't work.

  • Your comment on ggplot2 is correct, but see that the dims extend beyond -1 and +1, so this solution will throw out a lot of data.. – StupidWolf Nov 09 '19 at 16:06