This is my “because you can” rant.
Here, you can see a typical situation. You have some sales data that you want to represent using a bar plot.
Immediately, you notice a problem: the names on the X axis are not readable. One way to make the labels readable is to enlarge the graph.
Making larger graphs isn’t always possible. So, the next default solution is to rotate the text labels.
However, there is a problem. Rotated text is read more slowly than standard horizontal text. Don’t believe me? This is not an opinion but rather a result of empirical studies [ref], [ref]. Sometimes, rotated text is unavoidable. Most of the time, it is not.
So, how do we make sure all the labels are readable without rotating them? One option is to move them up and down so that they don’t hinder each other. It is easily obtained with Python’s matplotlib
plt.bar(range(len(people)), sales) plt.title('October sales') plt.ylabel('$US', rotation=0, ha='right') ticks_and_labels = plt.xticks(range(len(people)), people, rotation=0) for i, label in enumerate(ticks_and_labels): label.set_y(label.get_position() - (i % 2) * 0.05)
(note, that I also rotated the Y axis label, for even more readability)
Another approach that will work with even longer labels and that requires fewer code lines it to rotate the bars, not the labels.
… and if you don’t have a compelling reason for the data order, you might also consider sorting the bars. Doing so will not only make it prettier, it will also make it easier to compare between similar values. Use the graph above to tell whether Teresa Jackson’s sales were higher or lower than those of Marie Richardson’s. Now do the same comparison using the graph below.
To sum up: the fact you can does not mean you should. Sometimes, rotating text labels is the easiest solution. The additional effort needed to decipher the graph is the price your audience pays for your laziness. They might as well skip your graphs your message won’t stick.
This was my because you can rant.
Featured image by Flickr user gullevek