1

Based on the documentation provided, the set_num_colors command maxed out at 9 breaks for discrete variables in the choropleth package.

Is there anyway to go around this?

Thank you

choro <- CountyChoropleth$new(imp[[i]])
choro$title <- paste0(as.character(forImg$year[i]),"        ", "SGL RISK INDEX")
choro$ggplot_scale = scale_fill_viridis(name="Risks rank", discrete=TRUE, option="C" , na.value="grey50")
choro$set_num_colors(8)
choro$render() -> impImg
ggsave(filename=paste0("impImg", "-",i, ".png"), bg="white", dpi=175, height = 1080, width=1920, units = "px")
StochaK
  • 11
  • 1
  • Thank you for posting this question Billy. Can you please update the code to be a reproducible example as described here: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example. For example, you could use the built-in dataset `?df_pop_county`, which ships with the choroplethr, instead of `imp[[i]]`, which we don't have access to. – Ari Aug 11 '21 at 20:56
  • It's not a limitation of the `choropleth` package. It's a limitation from the palette. Use a discrete palette with more than 9 elements. – crestor Aug 11 '21 at 20:58
  • 1
    @Ari I will keep that in mind. Thank you – StochaK Aug 12 '21 at 15:14
  • Great. If you do that (give us code that we can run ourselves), someone can probably post a modification of that code that does what you want. – Ari Aug 12 '21 at 15:39

1 Answers1

0

You will need to build and use a color palette with enough elements:

https://www.datanovia.com/en/blog/easy-way-to-expand-color-palettes-in-r/

https://www.r-graph-gallery.com/40-rcolorbrewer-get-a-longer-palette.html

crestor
  • 1,388
  • 8
  • 21