Let’s Try Some Visualisation

An example of the value suppressing uncertainty scale. Great uses include forecast uncertainity.

Michael DeWitt https://michaeldewittjr.com

So I am going to try to use this blog to capture programming tricks and examples of R coding, data visualisation and general musing that I find interesting. This is mainly for personal use and as a nice memory tool.

Below is an example from Claus Wilke’s multiscales package. The details can be found here. I like that it uses geom_sf and one can also use the value suppressing uncertainity palettes. I often want to communicate uncertainity in cartographic mapping and this provides a much better way to do that. More on that article here.

So now for the example that one can use as…thanks Claus


colors <- scales::colour_ramp(
  colors = c(red = "#AC202F", purple = "#740280", blue = "#2265A3")

p<-ggplot(US_polling) + 
  geom_sf(aes(fill = zip(Clinton_lead, moe_normalized)), color = "gray30", size = 0.2) + 
  coord_sf(datum = NA) +
    pal_vsup(values = colors, max_desat = 0.8, pow_desat = 0.2, max_light = 0.7, pow_light = 1),
    name = c("Clinton lead", "uncertainty"),
    limits = list(c(-40, 40), c(0, 1)),
    breaks = list(c(-40, -20, 0, 20, 40), c(0, 0.25, 0.50, 0.75, 1.)),
    labels = list(waiver(), scales::percent),
    guide = "colourfan"
  ) +
  theme_void() +
    legend.key.size = grid::unit(0.8, "cm"),
    legend.title.align = 0.5,
    plot.margin = margin(5.5, 20, 5.5, 5.5)


If you see mistakes or want to suggest changes, please create an issue on the source repository.


Text and figures are licensed under Creative Commons Attribution CC BY 4.0. Source code is available at https://github.com/medewitt/medewitt.github.io, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".


For attribution, please cite this work as

DeWitt (2018, July 4). Michael DeWitt: Let's Try Some Visualisation. Retrieved from https://michaeldewittjr.com/programming/2018-07-04-let-s-try-some-visualisation/

BibTeX citation

  author = {DeWitt, Michael},
  title = {Michael DeWitt: Let's Try Some Visualisation},
  url = {https://michaeldewittjr.com/programming/2018-07-04-let-s-try-some-visualisation/},
  year = {2018}