Invert PCA generated graph

How can I invert/flip of PCA graph, please?

Here is the code:

mydata<- read.csv("Ikizdere.csv", TRUE, ",")
X=cbind (Temp., pH, EC, Perm_Ind, DO, CaCO3, o_PO4, TP, TSS, NO3_N, NO2_N, Chl_a, NH4_N, LAS, As, Cr, Cu, Mn, Ni, Pb, Zn)
res.pca <- princomp(X, scores=TRUE, cor=TRUE)

fviz_pca_var(res.pca, col.var="contrib",
             gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
             repel = TRUE # Avoid text overlapping


what exactly do you mean by invert/flip? Do you want to sort the y axis in the opposite direction? Reverse the x axis?

Because what you asked could be interpreted as this:


which is may or may not be what you want.

Thanks for the kind reply. From here you can check my two graphs (

Both graphs are same (of course with same meaning) but the direction of the vectors is in the opposite direction. I want to invert the first plot.

Please download the file so you could see both plots.

the direction of the vectors has meaning and it hardly seems something one would arbitrarily reverse. But you could swap the axes like this:

fviz_pca_var(res.pca, axes=c(2,1), col.var="contrib",
             gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
             repel = TRUE # Avoid text overlapping

I may be late in answering this, but I noticed the same difference when plot my PCA, wherein the axes were flipped depending on whether I used vegan or factominer.

A quick solution is to add + xlim(c(1,-1) + ylim(c(1,-1)). For instance,

fviz_pca_var(res.PCA, axes=c(1,2), repel=TRUE, col.var="contrib", gradient.cols=c("white","#f47a27", "#ed4040"), ggtheme=theme_minimal()) + xlim(c(1,-1) + ylim(c(1,-1))