【问题标题】:Highlighting specific countries (Ethiopia, Uganda, Kenya) using rworldmap library and map function使用 rworldmap 库和地图功能突出显示特定国家(埃塞俄比亚、乌干达、肯尼亚)
【发布时间】:2013-04-02 20:50:22
【问题描述】:

我在 ma​​pdata 包中使用此代码,但它只显示我选择的三个国家,而我看不到世界其他地区的地图边界。

map("world", 
    regions=c("ethiopia", "kenya", "uganda"), 
    exact = TRUE, 
    fill=TRUE, 
    col=c(1,2,3))

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

【问题讨论】:

    标签: r maps rworldmap


    【解决方案1】:

    这是一个没有 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)
    

    【讨论】:

    • +1,但我会使用 bor = "red" 或类似名称,以更加突出所选国家/地区。
    • 非常感谢西蒙。正是我想要的!完美!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-08
    • 1970-01-01
    • 2013-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多