- 3 Minutes Wednesdays
- Posts
- 3MW (A checklist for bar charts)
3MW (A checklist for bar charts)
Guten Tag!
Many greetings from Ulm, Germany.
Bar charts are easy to create but hard to perfect. Anyone can drop some data into a software tool and generate a bar chart. But what then?
Good design is in the details. And most people have seen hundreds of bar charts but are totally oblivious to the details.
So, today we're going through a couple of checks that a bar plot should pass. Here's a standard bar chart I've created with {ggplot2} using the {mpg} dataset. Let's improve it.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/04b67ba7-64bd-4af8-b8f9-d80af2e8e256/image.png)
Are bars ordered meaningfully?
Here, the bars are sorted alphabetically (by brand name). This can make sense sometimes. But most of the time I think it’s more convenient to sort the bars numerically. This makes it easier for the reader to compare numbers.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/6fdfa730-7687-408a-8019-1d96253b3176/image.png)
In the previous two plots, I have used only a selection of available brands from the data set. That’s because the axis labels would overlap if I use them all. This brings us to our next point.
Are labels on the y-axis?
Whether horizontal bars are always better than vertical bars is debatable. But when you have many bars or long labels, you should definitely opt for horizontal bars.
And please do not rotate the labels on the x-axis. There is a y-axis. Use it.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/9e7a911d-7e15-43bd-9897-0f7c74ba8a67/image.png)
Is the font large enough?
This is a totally obvious check but it's easy to forget.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/b32a3d3e-24f0-46f6-b7ef-df865a51ab1f/image.png)
Is there unnecessary spacing around labels?
Notice how there is a lot of space between the brands and the actual bars? There is really no reason that there is so much space. Maybe that’s only a problem with {ggplot2}. Maybe other software does that too. In any case, we should remove the extra spacing.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/b8a2bb97-002d-4bf3-b5a7-2e2d018cf6e7/image.png)
Is there clutter that we can remove?
There’s a lot of clutter due to the excessive use of grid lines. In our case, the horizontal grid lines make little sense. So let’s remove them.
While we’re at it, why not make the whole theme a bit lighter? Some people think of the grey background as clutter too.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/feb8ca4e-c169-475d-b741-9e0bf30fa621/image.png)
Do direct labels make sense?
We can avoid grid lines completely if we label the bars directly.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/0fd58389-dbcb-43f9-a223-1061e651abae/image.png)
You could even incorporate the y-axis labels into the bars. Then, you have to make sure that your labels fit into the bars. Maybe this involves abbreviating some of them.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/0125da6c-b229-4c1a-931c-098157a4037f/image.png)
(Optional) Are bars too thick?
This one is a matter of taste. Some people find thinner bars better. So you could try it for your bar chart as well. And when you’re making your bars thinner, you can arrange your labels a little bit differently too. Then, you have to make your plot larger or it will get messy.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/f3186e23-8221-4a0c-8b15-73d8375d6fd6/image.png)
That's a wrap! As always, I'm happy to hear your feedback about this week's issue. Feel free to write me on Twitter or reply to this mail.
Enjoy the rest of your day!Albert
Did you like this post and want to support more content like this? You can support me with a coffee or a membership.
Need help visualizing your data? Or need to build a Shiny app? I'm open to freelance work. You can book a free 30-minute Zoom meeting with me and we can find out if I'm a good match for your project.
Reply