2017-09-27 80 views
0

我使用macOS並將我的圖形文件保存爲pdf,jpeg和gif。但是在調整它們的大小時遇到​​麻煩。在Windows中,我們可以使用圖元文件評論。 有什麼評論像Windows在Mac?在R中保存繪圖

+0

另存爲SVG或pdf,然後在inkscape中操作。 –

回答

0

如果您在R中創建圖形並將其保存爲PDF,則可以使用參數widthheight以英寸爲單位調整圖形區域的大小。您也可以使用fonts參數更改字體大小在您的情節:

pdf("testplot.pdf", width=12, height=9, fonts=12) 
plot(1:10, rnorm(10, 0, 5)) 
dev.off() 

對於PNG,JPEG,TIFF或者BMP,您可以使用相同的邏輯,但要注意widthheight以像素爲單位進行測量(px)而不是英寸(in)。你可以手動改變它。請注意,對於不同的格式,您可以用jpeg()tiff()bmp()替換png()。另外請注意,你必須在res指定dpi(每英寸點數)如果設置units="in"

png("testplot.png", width=3, height=4, units="in", pointsize=12, res=300) 
plot(1:10, rnorm(10, 0, 5)) 
dev.off() 

與另一尺寸:

png("testplot2.png", width=3, height=3, units="in", pointsize=12, res=300) 
plot(1:10, rnorm(10, 0, 5)) 
dev.off() 

enter image description here enter image description here

+0

thanx很多爲您的詳細解釋。你救了我的命 :))).. –