Let’s Try Some Visualisation

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

Michael DeWitt https://michaeldewittjr.com
07-04-2018

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


library(ggplot2)
library(multiscales)

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

p<-ggplot(US_polling) + 
  geom_sf(aes(fill = zip(Clinton_lead, moe_normalized)), color = "gray30", size = 0.2) + 
  coord_sf(datum = NA) +
  bivariate_scale("fill",
    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() +
  theme(
    legend.key.size = grid::unit(0.8, "cm"),
    legend.title.align = 0.5,
    plot.margin = margin(5.5, 20, 5.5, 5.5)
  )
p

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. 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 ...".

Citation

For attribution, please cite this work as

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

BibTeX citation

@misc{dewitt2018let's,
  author = {DeWitt, Michael},
  title = {Michael DeWitt: Let's Try Some Visualisation},
  url = {https://michaeldewittjr.com/dewitt_blog/posts/2018-07-04-let-s-try-some-visualisation_files/},
  year = {2018}
}