rggplot2choroplethchoroplethr

Create more than 8 breaks for choroplethr in R?


I am trying to make a map that has a discrete color scale for EVERY fill unit.

Choropleth seems to limit the number of breaks to 8 or below.

I have 16 units (years) that I am trying to plot on a map, and its inconvenient to merge the different years.

example for stack over flow question

library(choroplethr)
library(ggplot2)
data(df_pop_county)
df_pop_county$value<-sample(1:15,nrow(df_pop_county),replace=T) #create some random variable of only 15 units
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()

Solution

  • Choroplethr maxes out at 9 for discrete.

    library(choroplethr)
    library(ggplot2)
    data(df_pop_county)
    df_pop_county$value<-sample(1:15,nrow(df_pop_county),replace=T) #create some random variable of only 15 units
    choro = CountyChoropleth$new(df_pop_county)
    choro$title = "2012 Population Estimates"
    choro$set_num_colors(9)
    choro$ggplot_scale = scale_fill_brewer(name="Population", palette=2, drop=FALSE)
    choro$render()
    

    2012 Population Estimates