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

眉间皱痕 提交于 2019-12-12 05:18:37

问题


I want to plot the result of a PCA with the package factominer. When one plots a PCA it is good practice to resize the graph so that its H/L ratio is in proportion to the %variance explained by each axis.

So I tried first to resize the graph simply by stretching the window: it obviously fails and keep the points in the middle instead of stretching them too.

library(FactoMineR)
out <- PCA(mtcars)

Then I try to force the xlim and ylim arguments to be fixed (?plot.PCA)

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

Same problem, the xlim limits are not respected...

Can someone explain this behaviour and knows how to fix it?


回答1:


What you're seeing is the result of the call to plot inside plot.PCA:

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

plot is called with parameter asp set to 1, which guarantees that the y/x ratio stays the same, so when you try to resize the window, the xlim are recomputed.

In plot.window you can find the "meaning" of asp:

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.

You can try

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

and resizing the window, and then the same with

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

to see the difference.



来源:https://stackoverflow.com/questions/40489711/set-axis-limits-for-plot-pca-strange-behaviour-factominer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!