I'm new to PCA. I'm plotting the scores using autoplot
from ggfortify
and ggplot
. Both have the same shape but have different values for the x and y axes. Eg. autoplot
goes from -0.2 to 0.2 in the y-axis, and ggplot
goes from -0.6 to -0.6. The points on the graphs look the exact same. Only the values of the axes changed. Why is that?
Edit: I can't really give the full data here as it's very long. I tried these two:
library(ggfortify)
pca.data <- prcomp(my_data)
autoplot(pca.data)
and
my_dataframe <- data.frame(Sample = rownames(pca.data$x),
X = pca.data$x[,1],
Y = pca.data$x[,2])
ggplot(data = my_dataframe, aes(x=X, y=Y, label=Sample)) +
geom_point() +
xlab("PC1") +
ylab("PC2") +
ggtitle("PCA Graph")
According to the vignette, autoplot scales in the same way as the biplot()
function. If you don't want it to, you can instead use:
autoplot(pca.data, scale=0)
which (except for axis labels) gives the same at the ggplot
command that you used.