How can I reverse the axis in a biplot

955 views Asked by At

When I plot a PCA and then the corresponding biplot, the axis are not always in the same direction, just like in these pictures:

plot(pc...) biplot(princomp...

These are the functions, I used:

(pc <- prcomp(dat5, center=T, retx=T, scale=T)); summary(pc)
plot(pc$x[,1:2], pch=""); text(pc$x[,1:2], cex=.5, labels=(row.names(dat5)), col=as.numeric(dat$ObCl))     
biplot(princomp(dat5, cor=T), cex=.5)

How can I change the axis direction of one of those, to make them the same?

1

There are 1 answers

5
Vincent Bonhomme On BEST ANSWER

The sign of PCs being arbitrary, you can change it/them by multiplying one or more PCs by -1. Note that this stands only for representation only, depending on what you do, eg if you use $rotation you may also need to change the corresponding columns as well. An example with iris follows. Hope this helps.

p <- prcomp(iris[, -5])
plot(p$x[, 1:2], asp=1, xlab="PC1", ylab="PC2")

enter image description here

plot(cbind(p$x[, 1], p$x[, 2]*-1), asp=1, xlab="PC1", ylab="PC2")

enter image description here