不幸的是,当我使用scale_fill_brewer
更改颜色时,我试图将美国的Choropleth Map格式化为特定的颜色。只有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()
关于r - 对于R中的County Choropleth map ,阿拉斯加和夏威夷的格式不正确,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38938565/