2017-08-04 142 views
1

我正在用10個變量繪製一個相關圖,使用方法=「數字」。我試圖導出大字體(number.cex = 3,tl.cex = 3)用於出版目的的繪圖,但這些方框的大小沒有增加以容納較大的字體。有沒有辦法修改這個?R Corrplot正方形(瓷磚)大小

這是我的代碼,如果有幫助:

corrplot(as.matrix(K), tl.cex = 3, tl.col = "black", method = "color", 
     outline = T, order="hclust", 
     addCoef.col = "black", number.digits = 2, number.cex = 3, 
     cl.pos = 'b', cl.cex = 3, addrect = 3, rect.lwd = 3, 
     col = colorRampPalette(c("midnightblue", "white","darkred"))(100)) 
+0

你有多大的矩陣K? – G5W

+0

10x10,它列出了10個變量中的每一個之間的成對關聯 – bashmike

回答

1

您應該調整圖形輸出文件的參數width,heightres
查看下面的示例。

set.seed(1) 
X = matrix(runif(1000),ncol=10) 
library(corrplot) 
png(file="corr.png", res=300, width=4500, height=4500) 
corrplot(as.matrix(cor(X)), tl.cex = 3, tl.col = "black", method = "color", 
     outline = T, order="hclust", 
     addCoef.col = "black", number.digits = 2, number.cex = 3, 
     cl.pos = 'b', cl.cex = 3, addrect = 3, rect.lwd = 3, 
     col = colorRampPalette(c("midnightblue", "white","darkred"))(100)) 
dev.off() 

enter image description here

1

可能是一個非常愚蠢的想法,但是這取決於你用什麼R版本,你可以簡單地去全屏幕,一旦彈出的窗口你運行你的corrplot()函數。這在過去對我有效。然後我想你應該確保選擇正確的格式;例如TIFF。

更復雜的解決方案當然是this。這裏的想法是一旦你寫入/保存它就調整圖形參數。那有意義嗎?

一般情況下,這個想法是這樣的(與互換格式類型):

tiff(filename=".tiff",width=...,height=...,res=...) 

jpeg() 

你可以嘗試的包是{grDevices}或{TIFF}和當然還有數百種。 ;)

讓我知道這是否適合你。

乾杯!

+0

另外,我瞭解到問題應該包含一個可重複的示例(請參閱[此處](https://stackoverflow.com/help/on-topic)和[here ](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example))。對我來說這是有道理的,因爲它讓別人更容易迴應,併爲你獲得有用的建議,對嗎?但我自己仍然在學習如何在stackoverflow上工作;) –