我似乎无法从空间对象的图中移除边距.在这种情况下,发布到其他类型图表的解决方案似乎不起作用.Par mai和oma参数也失败了.非常感谢您的建议.
library(maptools)
data(wrld_simpl)
bbox = cbind(c(179,179,-179,-179,179), c(89,-89,-89,89,89))
png('test.png', width=1000, height=500)
par(mai=c(0,0,0,0), oma=c(0,0,0,0))
plot(wrld_simpl, col='grey', bg='white', border=NA)
lines(bbox, col='red', lwd=3)
dev.off()
browseURL('test.png')
Run Code Online (Sandbox Code Playgroud)
红色边界框应该在图形输出边框内部绘制.

这将绘制没有边距的地图(虽然我仍然不知道这是否是你想要的).
require(maptools)
data(wrld_simpl)
# set up the output file
png('test.png', width=1200, height = 600, res = 300)
# define the plot and margins
par(ann = FALSE,
bg = "white",
bty = "n",
mai = c(0,0,0,0),
mgp = c(0, 0, 0),
oma = c(0,0,0,0),
omd = c(0,1,0,1),
omi = c(0,0,0,0),
usr = c(-180, 180, -90, 90),
pin = c(4,2),
plt = c(0,1,0,1),
pty = "m",
xaxs = 'i',
xaxt = 'n',
xpd = FALSE,
yaxs = 'i',
yaxt = 'n')
# plot the world map
plot(wrld_simpl,
col='grey',
bg='white',
border=NA,
ann=FALSE,
axes = FALSE)
# plot points at extremes
par(new = TRUE)
plot(c(0,0,-180,180),c(90,-90,0,0), type = "p", col = "red",pch="+", cex=0.5)
dev.off()
browseURL('test.png')
Run Code Online (Sandbox Code Playgroud)
