Data Visualization Patterns

How I build interactive articles, essays, & analyses for the web.

Desisions

One of the main reasons I switched from writing through Blogdown or Distill through R was I felt too limited by the existing styles and themes. I'm sure I could have accomplished what I wanted eventually, but it felt like I had to fight against what was already there and wasn't learning as much as if I started from scratch.

There are some tradeoffs between data visualization in R and JS that I had to learn through trial and error:

R advantages:

  • Unparalleled data analysis environment
  • Simple chart-making through ggplot
  • Statistical/ML packages usually have their own functions for visualizing models
  • If you are comfortable with default themes and styles, you only need to worry about the data and its analysis

JS advantages:

  • Full control over structure & styles with a better development experience for both (no re-knitting docs to see changes on the webpage)
  • Libraries for interactive web visualizations (Plot.ly, Mapbox, D3, Deck.gl, etc.)
    • Some of these are ported to R but generally give you less control over the API and tend to lag behind the JS version

This is not an exhaustive comparison and I plan to write in more depth about it soon, this is just to give some context on the tools available for the job.

Let's see some viz

Mapbox maps

Maps look good and can be customized based on whether the reader is using light or dark mode.
I can also use the map as a background in a scrollytelling document as is seen in many professional data journalism publications.
This means I can use transitions to add to the narration of the story. Let's do an example and narrate me moving from Baltimore to Philly.