How to Build a Brain-Friendly Bar Chart in R
This post was inspired by a post by Lea Pica: How to Build a Brain-Friendly Bar Chart in Domo. In that post, Lea started with the default rendering of a horizontal bar chart in Domo and then walked through, step-by-step, the modifications she would make to improve the visualization.
The default chart started like this:
And, it ended like this:
I thought it would informative to go through the exact same exercise, but to do it with R. Specifically, I used the ggplot2
package in R, which is the de facto standard for visualization with the platform.
I, too, started with the default rendering (with ggplot2)
of the same data set:
Egad!
But, I ultimately got to a final plot that was more similar to Lea’s Domo rendering than it was different:
The body of the bar chart is almost an exact replica (the gray with a blue highlight bar is something Lea showed as a “bonus,” but the title of the chart changed; it added an extra step, but I’m a big fan of this sort of highlighting, so that’s the version I built).
The exercise, as expected, does not wind up claiming either platform is a “better” one for the task. A few takeaways for me were:
- Both platforms are able to produce a good, quality, data-pixel-ratio-maximized visualization.
- Domo has some odd quirks: the “small, medium, or large” as the font size choices seems unnecessarily limiting, for instance.
- R has (more, I suspect) odd quirks: I couldn’t easily place the title all the way left-justified; putting the “large text higlight” would have been doable, but very hacky; The Paid Search data label crowds the top of the bar a bit (oddly), etc.
Ultimately, when developing visualizations with R, it takes very little code to do the core rendering of the visualization. It then — in my experience — takes 2-4X additional code to get the formatting just right. At the same time, though, much of that additional code operates like CSS — it can be centrally sourced and then used (and selectively overridden) by multiple visualizations.
If you’re interested in seeing the step-by-step evolution of the code from the initial plot to the final plot, you can check it out on RPubs (that document was put together as an RMarkdown file, so the code you see is, literally, the code that was then executed to generate the resulting iteration).
As always, I’d love to hear your feedback in the comments, and I’d love to chat about how R fits (or could fit) into your organization’s analytics technology stack!