为 plot.PCA 设置轴限制 - 奇怪的行为 (FactoMineR)

Set axis limits for plot.PCA - strange behaviour (FactoMineR)

我想用包 factominer 绘制 PCA 的结果。绘制 PCA 时,最好调整图形大小,使其 H/L 比率与每个轴解释的 % 方差成正比。

所以我首先尝试简单地通过拉伸 window 来调整图表的大小:它显然失败了并且将点保持在中间 而不是拉伸它们。

library(FactoMineR)
out <- PCA(mtcars)

然后我尝试强制修复 xlimylim 参数 (?plot.PCA)

plot.PCA(out, choix="ind", xlim=c(-6,6), ylim=c(-4, 4))

同样的问题,不遵守 xlim 限制...

有人可以解释这种行为并知道如何解决吗?

您看到的是在 plot.PCA 中调用 plot 的结果:

plot(0, 0, main = titre, xlab = lab.x, ylab = lab.y, 
     xlim = xlim, ylim = ylim, col = "white", asp = 1, ...)
调用

plot 时参数 asp 设置为 1,这保证 y/x 比率保持不变,因此当您尝试调整 window 的大小时,xlim 会重新计算。

plot.window中你可以找到asp的"meaning":

If asp is a finite positive value then the window is set up so that one data unit in the x direction is equal in length to asp * one data unit in the y direction.

你可以试试

plot(0, 0, main = "", xlab = "", ylab = "", xlim = c(-6, 6), ylim = c(-4, 4), col = "white", asp = 1)

并调整 window 的大小,然后与

相同
plot(0, 0, main = "", xlab = "", ylab = "", xlim = c(-6, 6), ylim = c(-4, 4), col = "white")

看看区别。