【发布时间】:2015-01-27 23:21:16
【问题描述】:
我是新来的,我正在尝试在沿海地区的地图上绘制点 - 因此我想展示一条海岸线并只为一个国家着色,周围是毗邻的国家。
我的代码是
library(maps)
library(mapdata)
map("worldHires", xlim=c(-90,-70), ylim=c(-20,-2), # Re-defines the latitude and longitude range
col = "gray", fill=TRUE)
但是我只想在秘鲁上色。到目前为止,我已经设法做到了:
map('worldHires', 'Peru', col = "grey90", fill=TRUE, xlim=c(-90,-70), ylim=c(-20,-2))
但这并没有显示毗邻的国家,我真的很想显示所有毗邻的国家,只是给秘鲁上色。
我在另一个线程中看到了使用简单地图工具的建议 - 但细节略少(见下文)
library(maptools)
data(wrld_simpl)
plot(wrld_simpl,
col = c(gray(.80), "red")[grepl("Peru", wrld_simpl@data$NAME) + 1],
xlim=c(-90,-70), ylim=c(-20,-2))
有谁知道如何使用 worldhire 来做到这一点?这可能真的很简单,只是我还没有解决。
【问题讨论】: