如何在同一个地块上绘制多个空间线:plot.new() 中的错误:图形边距太大
How to plot multiple SpatialLines on the same plot: Error in plot.new() : figure margins too large
我需要将 SpatialLines 对象旋转 90 度和 180 度,然后用旋转后的 SpatialLines 对象绘制原始 SpatialLines 对象。
然而,绘图函数提供了这个错误:
Error in plot.new() : figure margins too large
我正在使用 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)
我有时也会遇到这个错误,我将我的 X11 绘图最大化 window 然后它就消失了(虽然我不经常使用 RStudio)。即使在默认大小的查看器中,您提供的代码也适用于我。这段代码虽然产生了 3 个图。您可以使用 par
中的参数 new
将它们放在同一个地块上
plot(spl)
par(new=TRUE)
plot(spl90)
par(new=TRUE)
plot(spl180)
par(new=FALSE)
我会尝试写入文件,看看是否可行。
我需要将 SpatialLines 对象旋转 90 度和 180 度,然后用旋转后的 SpatialLines 对象绘制原始 SpatialLines 对象。
然而,绘图函数提供了这个错误:
Error in plot.new() : figure margins too large
我正在使用 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)
我有时也会遇到这个错误,我将我的 X11 绘图最大化 window 然后它就消失了(虽然我不经常使用 RStudio)。即使在默认大小的查看器中,您提供的代码也适用于我。这段代码虽然产生了 3 个图。您可以使用 par
new
将它们放在同一个地块上
plot(spl)
par(new=TRUE)
plot(spl90)
par(new=TRUE)
plot(spl180)
par(new=FALSE)
我会尝试写入文件,看看是否可行。