太平洋国家地图 [英] Plot Map of Pacific with filled countries

查看:274
本文介绍了太平洋国家地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用R的mapproj库中的World2Hires绘制太平洋地图,但是当我尝试填充各个国家/地区时会出现一个小故障.我该如何解决?

I'm trying to plot a map of the Pacific using World2Hires in R's mapproj library but there's an odd glitch when I try to fill the countries. How do I fix this?

library(maps)
library(mapproj)
library(mapdata)
map("world2Hires", 
    xlim=c(120, 260), 
    ylim=c(-60, 40), 
    boundary=TRUE, 
    interior=TRUE,
    fill=TRUE,
    col="gray30",
)
map.axes()

以下是输出:

推荐答案

问题似乎出在引起包装的小区域子集中.通过一些试验和错误保存原始的map调用(如mapnames <- map(...)),然后在新的调用中将此列表的子集传递给regions=参数,我可以避免围绕填充进行环绕.例如:

The issue seems to be with a small subset of areas which cause wrapping. From some trial and error saving the original map call like mapnames <- map(...) and then passing subsets of this list to the regions= argument in a new call, I could avoid the wrapping around of the fills. E.g.:

library(maps)
library(mapproj)
library(mapdata)
map("world2Hires", regions=mapnames$names[c(1:7,14:641)],
    xlim=c(120, 260), 
    ylim=c(-60, 40), 
    boundary=TRUE, 
    interior=TRUE,
    fill=TRUE
)
map.axes()

对于防止这种情况的更彻底或更明智的解决方案,我感到很沮丧.玩wrap=选项没有任何帮助,其他选项同样如此.附带说明,使用"world"数据库不会出现此问题,而只会弹出"world2""world2Hires"的情况.

As to a more thorough or sensible solution to prevent this happening, I am stumped. Playing with the wrap= option does nothing helpful, and likewise for the other options. As a side-note, this issue does not appear using the "world" database, but only pops up for "world2" and "world2Hires".

这篇关于太平洋国家地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆