0

我正在将一些图导出到 EPS 文件。我的代码是

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

但我发现绘图区域周围有(设备)边距。如何删除它们?谢谢你。

4

1 回答 1

2

那不是边际。请注意代码生成的 EPS 中没有轴、刻度线或图框。没有空间来绘制这些,并且图框将恰好位于 EPS 的边缘。

您看到的是 R 添加到轴限制的额外填充,以确保绘图字符位于绘图区域内,而不是在其边缘。IIRC 这个填充是 4%。

您可以分别使用 x 轴和 y 轴的xaxs和绘图参数来关闭它;yaxs?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()
于 2012-12-11T18:04:23.587 回答