【发布时间】:2013-07-17 21:04:36
【问题描述】:
我想在澳大利亚部分地区的地图中掩盖海洋。
这是我的出发点:
library(maps)
library(mapdata)
image(x=110:155, y =-40:-10, z = outer(1:45, 1:30, "+"),
xlab = "lon", ylab = "lat")
然后,按照此处发布的解决方案 (How can I color the ocean blue in a map of the US?),我设置了多路径:
outline <- map("worldHires", plot=FALSE) # returns a list of x/y coords
xrange <- range(outline$x, na.rm=TRUE) # get bounding box
yrange <- range(outline$y, na.rm=TRUE)
xbox <- xrange + c(-2, 2)
ybox <- yrange + c(-2, 2)
# create the grid path in the current device
polypath(c(outline$x, NA, c(xbox, rev(xbox))),
c(outline$y, NA, rep(ybox, each=2)),
col="light blue", rule="evenodd")][1]
但是,生成的地块在国家边界的任一侧都被掩盖了。谁能帮我只在国外戴口罩?
【问题讨论】:
-
map("worldHires", regions="australia", bg="light blue", fill=TRUE, xlim=c(110, 155), ylim=c(-40, -10))足够了吗?