2017-12-13 17 views
1

나는 미국 군대 수준의 데이터를 위해 스크립트 된 choropleth를 얻었으나 플로팅시에는 읽기가 어려워졌습니다. 카운티는 매우 혼잡 해져 서로 혼합되기 시작할 수 있습니다. 한 국가의 끝과 다른 지역의 시작을 알기가 어려워집니다. 누구든지 카운티 데이터로 choropleth지도를 작성하고 주별로 경계선 윤곽선을 만드는 방법을 알고 있습니까? 여기미국 군 수준 choropleth 정리하기

library(ggplot2) 
library(fiftystater) 
library(colorplaner) 
library(USAboundaries) 
library(sf) 

usc <- us_counties(resolution = c("low", "high"), states = NULL) 

st_list = c("Alabama", "Arizona", "Arkansas", "California", "Colorado", 
"Connecticut", "Delaware", "Florida", "Georgia", "Idaho", "Illinois", 
"Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", 
"Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", 
"Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New 
Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", 
"Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", 
"Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West 
Virginia", "Wisconsin", "Wyoming") 

plot_counties <- us_counties(states=st_list, resolution = 'high') 


plot_counties$dumb <- runif(nrow(plot_counties), 1,100) 

ggplot(plot_counties) + geom_sf(aes(fill=dumb)) + 
    scale_x_continuous(breaks = NULL) + 
    scale_y_continuous(breaks = NULL) + 
    scale_fill_gradientn("Title", 
         colours = c('darkred', 'tomato1', 'cyan2', 
         'darkblue'), 
         values = c(0,.5,.5000001, 1)) + 
    theme(panel.background = element_blank(), axis.ticks = element_blank(), 
     axis.text = element_blank()) 

답변

1

possibile 솔루션입니다 :

plot_counties <- us_counties(states=st_list, resolution = 'high') 
plot_counties$dumb <- runif(nrow(plot_counties), 1,100) 
plot_states <- us_states(states=st_list, resolution = 'high') 

ggplot(plot_counties) + 
    geom_sf(aes(fill=dumb), color=NA) + 
    geom_sf(data=plot_states, fill=NA, color="black", lwd=1) + 
    scale_x_continuous(breaks = NULL) + 
    scale_y_continuous(breaks = NULL) + 
    scale_fill_gradientn("Title", 
         colours = c('darkred','tomato1','cyan2','darkblue'), 
         values = c(0,.5,.5000001, 1)) + 
    theme(panel.background = element_blank(), axis.ticks = element_blank(), 
     axis.text = element_blank()) 

enter image description here

+0

정말 영리한 해결책 여기에 내가 재생을 위해 지금까지 가지고있는 코드입니다. 고맙습니다! – lostpineapple45