2016-11-08 16 views
0

我想繪製一個PCA與包factominer的結果。當繪製PCA圖時,最好調整圖的大小,使其H/L比與各軸解釋的百分比變化成比例。設置plot.PCA的軸限制 - 奇怪的行爲(FactoMineR)

因此,我首先嚐試通過拉伸窗口來調整圖形大小:它明顯失敗並將點保留在中間而不是拉伸它們。

library(FactoMineR) 
out <- PCA(mtcars) 

enter image description here

然後我試圖迫使xlimylim參數是固定的(?plot.PCA

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

enter image description here

同樣的問題,該XLIM限制不被尊重...

有人可以解釋這種行爲,並知道如何解決它?

回答

1

你看到的是調用plotplot.PCA結果:

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

plot被調用的參數asp設置爲1,這保證了Y/X比保持不變,所以當你嘗試調整窗口大小時,xlim被重新計算。

plot.window可以找到的asp「意」:

如果ASP是一種有限正值,則設置窗口向上,以便在x方向上的一個數據單元等於在長度爲ASP * y方向上有一個數據單元。

您可以嘗試

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

和調整窗口大小,然後用相同

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

看出區別。

+0

謝謝,現在我明白髮生了什麼。那麼我可以從PCA陰謀中刪除這個選項嗎?我試圖設置不同的值,但我得到一個錯誤 – agenis

+0

我想你可以直接採取行動的情節調用,但你將不得不修改plot.PCA功能 – Cath

+0

好吧,這就是我懷疑。謝謝你的幫助。我會接受答案。 A + – agenis