R语言可视化作图笔记(3)地理空间可视化

地理空间可视化(Geospatial Visualization)

aegypti_albopictus.csv是一个包含了全球各地历年受到Aedes aegypti与Aedes albopictus两种蚊子感染登革热患者的统计数据。COUNTRY和COUNTRY_ID为各地名称与缩写。

plotly::plot_geo

通过plotly自带的地图,我们可以直接画出很棒的地图。下图是用plot_geo画出的历年各地受灾人数的总和在各地分布情况。

library(plotly)
data <- read.csv(file="aegypti_albopictus.csv")
data2 <- data
data2$NUM <- 1           # 求和
data3 <- aggregate(NUM ~ COUNTRY + COUNTRY_ID, data2, sum)
plot_geo(data3) %>%
  add_trace(
    # z = ~log(NUM), 
    z = ~NUM, 
    color = ~NUM, colors = 'Reds',
    # text = ~paste(COUNTRY, NUM, sep = "
"), text = ~COUNTRY, locations =~COUNTRY_ID )%>% layout(geo = list( scope = "world", showland = TRUE, landcolor = toRGB("gray80")

你可能感兴趣的:(R的数据可视化笔记,R编程)