Why avoid dual-axis charts?
See how a chart with two vertical axes tells whatever story its maker wants, and swap it for two charts that don't mislead.
Free course. Your Maestro, an AI, .
In a presentation, someone wants to show that Centro's sales "go hand in hand" with the number of customers. They put both measures in a single chart: sales in pesos with their axis on the left and tickets with their axis on the right. The two lines rise and fall together, almost on top of each other. It looks like proof.
The problem is that the two measures have different units (hundreds of thousands of pesos against thousands of tickets), so each one needs its own axis, and whoever makes the chart decides where each one starts and ends. Moving an axis raises or lowers its whole line, stretches it or flattens it, without changing a single data point. Lisa Charlotte Muth explains it on the Datawrapper blog: the scales of a dual-axis chart are arbitrary, so they can mislead readers about the relationship between the two measures, sometimes on purpose.
See it with Centro's data (synthetic). First, the presentation's version.
Now the same data, with other ranges on the axes. Nothing else changed.
In version A, sales and tickets look like twins. In B, the tickets seem not to move at all while sales go up and down. Both charts are "correct": every point is where it should be on its axis. What changed is the decision of whoever made them. That's why a crossing between the two lines, or the lines running parallel, means nothing on its own: with other ranges they would cross in another month, or never.
When you read a chart like this, the "axes and baseline" move has an extra question: is there a second axis on the other side? If there is, distrust any conclusion that depends on where the lines sit relative to each other.
What to do instead
The first solution the Datawrapper article proposes is two separate charts, one per measure. Here you'll stack them, one above the other, with the same time axis at the bottom so the months line up. Each measure gets its own axis, without fighting over the same space, and the eye can compare in which months both rise or fall. The second one it proposes is an indexed chart: both measures start at 100 in January and you see how much each changed proportionally, on a single scale.
Try it
This code draws Centro's dual-axis chart. Turn it into two charts, one above the other.
Make one change: on the last line, replace alt.layer(ventas, tickets).resolvescale(y="independent") with alt.vconcat(ventas, tickets). layer puts the two charts on top of each other; vconcat stacks them one above the other. (The code is in Spanish: ventas is sales, mes the month,
Your turn
Make one change: on the last line, replace alt.layer(ventas, tickets).resolve_scale(y="independent") with alt.vconcat(ventas, tickets). layer puts the two charts on top of each other; vconcat stacks them one above the other. (The code is in Spanish: ventas is sales, mes the month, and the axis titles say Ventas for sales and punteada for dotted.)
You're done when you see two charts, sales on top and tickets below, each with its own axis. Compare the months: in which ones do both go up, and in which ones don't they?
The chart redraws when you pause typing, or right away with Run. Ctrl+Enter runs it. Tab indents; to leave the editor, press Escape, then Tab.
Ready to run your code.
Data: ventas-mensuales, 72 rows
Enter saves a cell and Escape leaves it as it was. Leave a cell empty for a missing value.
| Row | Remove | ||||
|---|---|---|---|---|---|
| 1 | |||||
| 2 | |||||
| 3 | |||||
| 4 | |||||
| 5 | |||||
| 6 | |||||
| 7 | |||||
| 8 | |||||
| 9 | |||||
| 10 | |||||
| 11 | |||||
| 12 | |||||
| 13 | |||||
| 14 | |||||
| 15 | |||||
| 16 | |||||
| 17 | |||||
| 18 | |||||
| 19 | |||||
| 20 |
What's an indexed chart? Ask your Maestro to explain it with Centro's sales and tickets.
Separated, each line is read against its own axis and there's no crossing left to interpret. You can see, for example, that in January both are at their highest, but that in September tickets drop while sales barely move: people bought less often, but more each time.
If you have to present two measures with different units, tell your Maestro what they are and what you want the reader to see.