2016-08-14 57 views
5

我想格式化美國的Choropleth地圖到一個特定的顏色,不幸的是,當使用scale_fill_brewer來改變顏色;只有48個州(夏威夷和阿拉斯加沒有)。是否有可能知道我是否可以將顏色實施到夏威夷和阿拉斯加?阿拉斯加和夏威夷沒有正確格式化爲縣Choropleth地圖在R

library(choroplethr) 
library(choroplethrMaps) 
library(ggplot2) 
data(df_pop_county) 

county_choropleth(df_pop_county, title = "Title1", legend = "Top 20% of Index", num_colors = 9) + 

geom_polygon(aes(fill=value), color="white") + 

scale_fill_brewer(name="Top Index", palette="YlOrRd") 

回答

4

要使用此選項,並已將其如下正確地更新,我們可以work with it as an R6 object所有國家:

library(choroplethr) 
library(choroplethrMaps) 
library(ggplot2) 
data(df_pop_county) 

choro    = CountyChoropleth$new(df_pop_county) 
choro$title  = "2012 Population Estimates" 
choro$ggplot_scale = scale_fill_brewer(name="Population", palette=2, drop=FALSE) 
choro$render() 

enter image description here

使用你所提到的具體的托盤:

choro    = CountyChoropleth$new(df_pop_county) 
choro$title  = "2012 Population Estimates" 
choro$ggplot_scale = scale_fill_brewer(name="Population", palette="YlOrRd", drop=FALSE) 
choro$render() 

enter image description here

相關問題