阿拉斯加州和夏威夷州没有正确格式化R县的县Choropleth地图 [英] Alaska and Hawaii not formatting correctly for County Choropleth Map in R
本文介绍了阿拉斯加州和夏威夷州没有正确格式化R县的县Choropleth地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将美国的Choropleth Map格式化为特定的颜色,不幸的是,当使用 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)
解决方案
要使用此选项并正确更新所有状态,我们可以
使用您提到的特定托盘:
choro = CountyChoropleth $ new(df_pop_county)
choro $ title =2012人口估计
choro $ ggplot_scale = scale_fill_brewer(name =Population,palette =YlOrRd,drop = FALSE)
choro $ render()
I am trying to format a Choropleth Map of the United States to a specific color and unfortunately, when using scale_fill_brewer
to change the color; only 48 of the states do (Hawaii and Alaska do not). Is it possible to know if I can implement the coloring to Hawaii and Alaska as well?
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")
解决方案
To use this option and have it properly update all states we can work with it as an R6 object as follows:
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()
Using the particular pallet you mentioned:
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()
这篇关于阿拉斯加州和夏威夷州没有正确格式化R县的县Choropleth地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文