2
考虑下述R代码在plotly生产地区分布图:plotly地区分布图:显示国名
#devtools::install_github("ropensci/plotly")
library(plotly)
df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv')
# light grey boundaries
l <- list(color = toRGB("grey"), width = 0.5)
# specify map projection/options
g <- list(
showframe = FALSE,
showcoastlines = FALSE,
projection = list(type = 'Mercator')
)
plot_ly(df, z = GDP..BILLIONS., text = COUNTRY, locations = CODE, type = 'choropleth',
color = GDP..BILLIONS., colors = 'Blues', marker = list(line = l),
colorbar = list(tickprefix = '$', title = 'GDP Billions US$'),
filename="r-docs/world-choropleth") %>%
layout(title = '2014 Global GDP<br>Source:<a href="https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html">CIA World Factbook</a>',
geo = g)
是否有plotly内置的选项,以显示在地图上的国名?如果不是,那么编码这种方法的聪明方式是什么?
查看例如:https://plot.ly/r/choropleth-maps/
安装说明plotly:https://plot.ly/r/getting-started/
如果你真的需要国名,以帮助人们了解地理,也许条形图是该可视化是更好的选择。另外[固定]因为情节不在CRAN中,有些人可能需要安装说明。最后,国家名称在弹出窗口(这是使用交互式可视化的实际点)。 – hrbrmstr
@hrbrmstr整个观点更多的是美化地图而不是教地理;) – kanimbla
我们对于什么使得统计地图“美丽”的观点有不同的看法。 – hrbrmstr