The sky is gray here, and Iβve got a delightful cup of tea in hand. The perfect setup to share another nugget of dataviz wisdom with you, all in under 3 minutes as usual. π
If you work in data analytics or data visualization, thereβs a debate youβre almost guaranteed to encounter at some point:
β
Dual Y-Axis Charts: Good or Bad?
π±π±π±π±π±
For the uninitiated, a dual Y-axis chart uses 2 vertical axes on either side of the chart to represent 2 variables with distinct scales, plotted against a shared horizontal axis. β It looks like this! (R tutorial on the left, Python on the right:
This topic sparks endless debate! π
β
Short answer: Theyβre bad.
Hadley Wickham, the creator of ggplot2, famously avoided implementing dual Y-axis functionality in the library. He even explained his reasoning on Stack Overflow.
My favorite dataviz blogger, Lisa, wrote a brilliant blog post on this topic. Not only does she break down why dual Y-axis charts are problematic, but she also offers some fantastic alternatives!
When I was a software engineer at Datadog, I faced the same dilemma. Despite my reservations, client demand pushed us to implement dual Y-axis charts using D3.js and React. π
β
So, why are they bad?
Reason 1: They are hard to read, and it is proved that people get them wrong in this research paper.
Reason 2: You can easily manipulate the axis limits to tell any story you want. A small tweak to those limits, and suddenly, the narrative shifts in your favor.
It features a dual Y-axis chart showing the GDP growth of the world (left axis) and France (right axis). By adjusting the axis limits, you can make it seem like one is growing faster than the other. Or the opposite.π±
Same data, different limits for the second axis. And that's it, you have a different story. Try the playground!
β
Takeaway
Dual Y-axis charts are misleading. If you need a quick way to prove it, check out my interactive playground. If you have more time, I highly recommend reading Lisaβs blog post!
Hope it helps, and see you next week! π
Yan β βPS: if you want to learn how to make interactive graphs like this, please let me know! I'm hesitant to create a workshop to introduce d3 to R/Python users β βPPS: this week we shipped the third module of Matplotlib Journey and reached 250 students!! π³ This means the price will increase in a few days. Come and join us! β