【发布时间】:2015-01-19 14:31:15
【问题描述】:
我需要将 SpatialLines 对象旋转 90 度和 180 度,然后用旋转的 SpatialLines 对象绘制原始 SpatialLines 对象。
然而,绘图功能提供了这个错误:
plot.new() 中的错误:图边距太大
我正在使用 RStudio。我尝试重新启动 R Session,重新启动 RStudio 并通过转到 Plots->Zoom Plot 手动缩小绘图...但这无助于解决问题。
library(sp)
library(maptools)
x <- c(1,5,4,8)
y <- c(1,3,4,5)
xy <- cbind(x,y)
xy.sp = sp::SpatialPoints(xy)
spl <- sp::SpatialLines(list(Lines(Line(xy.sp), ID=i)))
# Rotation of a SpatialLines object
spl90 <- maptools::elide(spl, rotate=90, center=apply(bbox(spl), 1, mean))
spl180 <- maptools::elide(spl, rotate=180, center=apply(bbox(spl), 1, mean))
plot(spl)
plot(spl90)
plot(spl180)
【问题讨论】:
-
在 RStudio 0.98 上使用 R 3.1、sp 1.0 和 maptools 0.8-29 没有问题。这三个图中的哪一个会产生错误?如果将
x11()放在绘图命令之前会发生什么? -
@koekenbakker:谢谢!在 plot 命令之前添加 x11() 解决了问题。