早上好,我花了很多时间弄清楚如何在情节上直接添加国家名称,而不是像传奇的一部分,而是像地图的一部分.我正在使用包rworldmap,尝试使用identifyCountries ()- 但它是用于交互的东西(当用户点击地图时),而不是我找到了一个这样的解决方案
一个国家的行政区域地图与ggmap和ggplot2,但它是ggplot2,太复杂了.我试着这样做mapCountryData().希望对你有所帮助,谢谢.
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")
Run Code Online (Sandbox Code Playgroud)
你可以试试:
# 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))
Run Code Online (Sandbox Code Playgroud)
在你的代码之后传递这些行,你会得到:

| 归档时间: |
|
| 查看次数: |
2943 次 |
| 最近记录: |