2012-12-11 37 views
0

我正在將一些圖導出到EPS文件。我的代碼是如何刪除EPS文件的設備頁邊距

setEPS() 
postscript("test.eps") 
par(mar=c(0,0,0,0)) 
plot(1:10) 
dev.off() 

但我發現繪圖區周圍有(設備)邊距。如何刪除它們?謝謝。

+0

請不要從根本上改變你的問題了一段時間後* *張貼。我已經回到原來的狀態了,因爲我提供的答案在您的重大變化之後沒有任何意義。請開始一個新的問題。 –

+0

謝謝@GavinSimpson,這是我第二次考慮後的新問題:http://stackoverflow.com/q/13826521/688080 – ziyuang

回答

2

這不是保證金。注意您的代碼生成的EPS中沒有座標軸,刻度線或圖框。沒有空間來繪製這些,情節框架將完全位於EPS的邊緣。

您所看到的是R添加到軸限制以確保繪圖字符位於繪圖區域內而不是邊緣上的額外填充。 IIRC這個填充是4%。

您可以分別使用xaxsyaxs繪製x軸和y軸的參數來關閉此功能;看到?par

‘xaxs’ The style of axis interval calculation to be used for the 
     x-axis. Possible values are ‘"r"’, ‘"i"’, ‘"e"’, ‘"s"’, 
     ‘"d"’. The styles are generally controlled by the range of 
     data or ‘xlim’, if given. 
     Style ‘"r"’ (regular) first extends the data range by 4 
     percent at each end and then finds an axis with pretty labels 
     that fits within the extended range. 
     Style ‘"i"’ (internal) just finds an axis with pretty labels 
     that fits within the original data range. 
     ** editted for brevity ** 
     (_Only ‘"r"’ and ‘"i"’ styles have been implemented in R._) 

默認爲"r",改用:

setEPS() 
postscript("test.eps") 
par(mar=c(0,0,0,0), xaxs = "i", yaxs = "i") 
plot(1:10) 
dev.off() 
+0

謝謝。我以前遇到過這個選項,但當時並不清楚這個選項的含義。 – ziyuang