ase*_*ran 7 maps r ggplot2 choropleth choroplethr
我试图将美国的等值线图格式化为特定的颜色,不幸的是,当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")
Run Code Online (Sandbox Code Playgroud)
要使用此选项并正确更新所有状态,我们可以将其作为R6对象使用,如下所示:
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()
Run Code Online (Sandbox Code Playgroud)
使用您提到的特定托盘:
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()
Run Code Online (Sandbox Code Playgroud)