1

背景

我正在绘制以下图像:

在此处输入图像描述

使用此代码:

par(mfrow = c(2, 2),
    mar = c(2, 2, 2, 2))

plot(1, col = "red", pch = 15)
plot(1, col = "blue", pch = 15)
plot(1, col = "orange", pch = 15)
plot(1, col = "purple", pch = 15)

我想使用grImport(包括示例数据)添加一个外部 postscript 文件:

library(grImport)
#PostScriptTrace("drawing.ps")
#pic <- readPicture("drawing.ps.xml")

# generated with dput()
pic <- new("Picture",
           paths = list(path = new("PictureFill", rule = "nonzero",
                                   x = c(move = 0, line = 1315.47, line = 1315.47, line = 0, 
                                         line = 0),
                                   y = c(move = 1080, line = 1080, line = 7.37891, 
                                         line = 7.37891, line = 1080),
                                   rgb = "#D0D1E6", lty = numeric(0), 
                                   lwd = 10, lineend = 1, linejoin = 1, linemitre = 10)),
           summary = new("PictureSummary", 
                         numPaths = 1, xscale = c(xmin = 0, xmax = 1315.47),
                         yscale = c(ymin = 7.37891, ymax = 1080)))

grid.picture(pic)

这只是让 ps 图像填充整个绘图设备:

在此处输入图像描述

问题

我希望紫色方块准确地绘制在一个绘图区域的顶部(比如说左上角)。

如何提取plot()整个设备参考系中第一个的坐标?

一旦我有了这些,如何正确使用坐标grid.picture()

4

0 回答 0