我正在尝试将美国的 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")
要使用此选项并让它正确更新我们可以的所有状态将其作为 R6 对象使用 https://cran.r-project.org/web/packages/choroplethr/vignettes/c-county-choropleth.html如下:
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()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)