高级人口统计制图

在 R 中分析美国人口普查数据

Kyle Walker

Instructor

制图中的视觉变量

Axis Maps 的视觉变量

在 R 中分析美国人口普查数据

分级符号地图

library(sf)

centers <- st_centroid(state_value)

ggplot() + geom_sf(data = state_value, fill = "white") + geom_sf(data = centers, aes(size = estimate), shape = 21, fill = "lightblue", alpha = 0.7, show.legend = "point") + scale_size_continuous(range = c(1, 20))
在 R 中分析美国人口普查数据

分级符号

在 R 中分析美国人口普查数据

分面图

在 R 中分析美国人口普查数据

使用 ggplot2 的分面地图

ggplot(dc_race, aes(fill = percent, color = percent)) + 
  geom_sf() + 
  coord_sf(datum = NA) + 
  facet_wrap(~variable)

分面地图

在 R 中分析美国人口普查数据

交互式可视化

  • 基于网页的图形支持交互

  • R 中的选项:

    • leaflet
    • plotly
    • htmlwidgets
在 R 中分析美国人口普查数据

使用 mapview 的交互式地图

library(mapview)
mapview(cook_value, zcol = "estimate", legend = TRUE)

mapview 动图

在 R 中分析美国人口普查数据

开始练习!

在 R 中分析美国人口普查数据

Preparing Video For Download...