阿拉斯加和夏威夷在 R 中的 County Choropleth Map 格式不正确

Alaska and Hawaii not formatting correctly for County Choropleth Map in R

我正在尝试将美国的 Choropleth 地图格式化为特定颜色,不幸的是,当使用 scale_fill_brewer 更改颜色时;只有 48 个州这样做(夏威夷和阿拉斯加没有)。是否可以知道我是否也可以在夏威夷和阿拉斯加实施着色?

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")

要使用此选项并使其正确更新所有状态,我们可以 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()

使用您提到的特定托盘:

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()