연속 구분 구역도(Choropleth)

R로 배우는 plotly 인터랙티브 데이터 시각화

Adam Loy

Statistician, Carleton College

R로 배우는 plotly 인터랙티브 데이터 시각화

세계 인구밀도 지도

R로 배우는 plotly 인터랙티브 데이터 시각화

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
R로 배우는 plotly 인터랙티브 데이터 시각화

plotly의 연속 구분 구역도

turnout %>%

plot_geo(locationmode = 'USA-states') %>%
add_trace( z = ~turnout, # 색상 값 설정 locations = ~state.abbr # 도형과 사례 매칭 ) %>%
layout(geo = list(scope = 'usa')) # 미국으로만 제한
R로 배우는 plotly 인터랙티브 데이터 시각화

plot_geo()의 제한 사항

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

R로 배우는 plotly 인터랙티브 데이터 시각화

매핑 옵션

scope = "usa"

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

projection = list(type = "mercator")

  • "conic conformal" | "mercator" | "robinson" | "stereographic" | 외 18개...

scale = 1

  • 값이 클수록 더 많이 확대됨

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

  • c.lat, c.lon으로 중심 설정
R로 배우는 plotly 인터랙티브 데이터 시각화

이제 매핑해 봅시다!

R로 배우는 plotly 인터랙티브 데이터 시각화

Preparing Video For Download...