Choropleth-kaarten

Interactieve datavisualisatie met plotly in R

Adam Loy

Statistician, Carleton College

Interactieve datavisualisatie met plotly in R

800px-World_human_population_density_map.png

Interactieve datavisualisatie met plotly in R

Choropleth-kaarten in plotly

head(turnout)
       state state.abbr turnout2018 turnout2014  ballots      vep      vap
1    Alabama         AL       0.474       0.332  1725000  3641209  3802714
2     Alaska         AK       0.537       0.548   280000   521777   554426
3    Arizona         AZ       0.486       0.341  2385000  4910625  5519036
4   Arkansas         AR       0.412       0.403   895000  2171940  2319740
5 California         CA       0.478       0.307 12250000 25635139 30836229
6   Colorado         CO       0.619       0.547  2540000  4103903  4445013
Interactieve datavisualisatie met plotly in R

Choropleth-kaarten in plotly

turnout %>%

plot_geo(locationmode = 'USA-states') %>%
add_trace( z = ~turnout, # Stelt de kleurwaarden in locations = ~state.abbr # Koppelt cases aan polygonen ) %>%
layout(geo = list(scope = 'usa')) # Beperkt kaart tot alleen de VS
Interactieve datavisualisatie met plotly in R

Beperking van plot_geo()

locationmode: "USA-states" | "ISO-3" | "country names"

Interactieve datavisualisatie met plotly in R

Kaartopties

scope = "usa"

  • "world" | "usa" | "europe" | "asia" | "africa" | "north america" | "south america"

projection = list(type = "mercator")

  • "conic conformal" | "mercator" | "robinson" | "stereographic" | en 18 meer...

scale = 1

  • Hogere waarden = meer inzoomen

center = list(lat = ~c.lat, lon = ~c.lon)

  • Stel c.lat en c.lon in om de kaart te centreren
Interactieve datavisualisatie met plotly in R

Aan de slag met mappen!

Interactieve datavisualisatie met plotly in R

Preparing Video For Download...