使用rworldmap库和地图功能突出显示特定国家(埃塞俄比亚,乌干达,肯尼亚)

Car*_*lho 7 maps r rworldmap

我使用包mapdata使用此代码,但它只显示我选择的三个国家,我看不到世界其他地图边界.

map("world", 
    regions=c("ethiopia", "kenya", "uganda"), 
    exact = TRUE, 
    fill=TRUE, 
    col=c(1,2,3))
Run Code Online (Sandbox Code Playgroud)

在突出显示我选择的三个国家的同时,如何展示世界其他地图的边界?

EDi*_*EDi 10

这是一个没有rworldmap的例子:

require(mapdata)

# get the names
cc <- map('world', names = TRUE, plot = FALSE)
take <- unlist(sapply(c("ethiopia", "kenya", "uganda"), grep, tolower(cc), value = TRUE))

# world
map()
# add the selected countries in grey to the plot
map('world', regions=take, fill=TRUE, col='grey50', add = TRUE)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

  • +1,但我会使用`bor ="red"或类似的东西来突出显示选定的国家/地区. (2认同)