首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用rworldmap显示的地块上的国家名称

用rworldmap显示的地块上的国家名称
EN

Stack Overflow用户
提问于 2015-02-12 04:42:35
回答 1查看 4K关注 0票数 4

早上好,我花了很多时间想办法把一个国家的名字直接加在情节上--不是传说的一部分,而是地图的一部分。我正在使用软件包rworldmap,尝试使用identifyCountries () --但是它适用于交互(当用户单击地图时),而不是我已经找到了这样的解决方案-- Administrative regions map of a country with ggmap and ggplot2,但它是针对ggplot2的,而且太复杂了。我试着用mapCountryData()做这件事。希望你能帮忙谢谢。

代码语言:javascript
复制
data <- data.frame(Country=c('Russia','Cyprus', 'Belize', 'Austria' ,'Virgin Islands', 
        'Italy','United States' ,'United Kingdom', 'Germany', 'France' ,'Poland' ,'Switzerland'),
Value=c(-0.310,-0.206,-0.300,-0.179,-0.196,-0.174,-0.105,-0.142,-0.082,-0.097,-0.027,0.052))

    library('rworldmap')

    pdf1 <- joinCountryData2Map(data, joinCode="NAME", nameJoinColumn="Country")

    mapCountryData(pdf1, nameColumnToPlot="Value", catMethod="pretty", 
    colourPalette='white2Black',addLegend='TRUE',mapTitle=NULL, mapRegion="Europe")
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-12 07:55:58

你可以试试:

代码语言:javascript
复制
# get the coordinates for each country
country_coord<-data.frame(coordinates(pdf1),stringsAsFactors=F)
# label the countries
text(x=country_coord$X1,y=country_coord$X2,labels=row.names(country_coord))

在代码后传递这些行,您将得到:

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28469444

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档