Independent vertical scales can manufacture alignment; compare shared-time alternatives first.
Dual-axis charts: test whether two series really need one plot
Two axes create a choice
A dual-axis chart places two measures against a shared horizontal dimension while giving each its own vertical scale. It can be compact, but independent scale ranges allow almost any pair of trends to look aligned or opposed. State both units, put each series next to its axis label, and inspect the same data as separate aligned panels before publishing. Small multiples preserve time alignment without implying that pixel height has a shared meaning.
Audit the apparent correlation
The eye can mistake coincident peaks for a relationship when one series has been shifted, smoothed or clipped. If the question is whether the measures co-vary, use paired observations in a scatter plot and name any lag rather than inferring it from two lines. Correlation coverage matters when dates are missing from one source. Do not quietly forward-fill one series to align timestamps. Carry measurement cadence and missingness into the displayed record.
When shared axes are possible
If the two series have the same unit and meaning, use a single axis. If they differ only by a constant conversion, convert one before plotting and disclose the conversion. If they have unrelated units but the question is relative change from a baseline, an indexed chart can be clearer, provided the base period and undefined zero-base cases are stated. Transformed scales also demand explicit zero handling. A second axis is not a shortcut around incompatible denominators.
Keep exports and text independent
When a second axis is justified by a particular reading task, export both raw series, scale domains, ticks and units. Use distinct line patterns, not just colors, and name the axes in a text summary. Test the chart with one series removed; readers should still know which axis belongs to the remaining series. The chart manifest should record every transformation and scale domain. Check mobile width: overlapping axis labels can erase the distinctions that made the chart defensible.
Worked contract
from math import isfinite
def paired_series_rows(
first: dict[str, float], second: dict[str, float]
) -> tuple[list[tuple[str, float, float]], list[str]]:
if any(not isfinite(value) for value in [*first.values(), *second.values()]):
raise ValueError("series values must be finite")
shared = sorted(first.keys() & second.keys())
missing = sorted(first.keys() ^ second.keys())
return [(period, first[period], second[period]) for period in shared], missing
requests = {"week-47": 81, "week-48": 97, "week-49": 113}
latency = {"week-47": 59, "week-49": 68, "week-50": 83}
pairs, unpaired = paired_series_rows(requests, latency)
assert pairs == [("week-47", 81, 59), ("week-49", 113, 68)]
assert unpaired == ["week-48", "week-50"]Performance and operating cost
For A and B keyed observations, set intersection and sorting use O(A+B+K log K) time and O(A+B) additional space for K paired periods. This preparation does not select axis domains or establish a correlation. It prevents silent alignment by index position. A production chart should also validate time-zone and aggregation-period equivalence before treating two keys as the same time.
Common Mistakes
- Choosing independent axis domains solely to align peaks.
- Forward-filling missing dates without a stated imputation rule.
- Using two axes for measures that share a convertible unit.
- Relying on color alone to tie each line to its axis.
Validation drill
Plot weekly requests and latency for 47 weeks as separate aligned panels and as a dual-axis view. Remove two latency weeks and verify the paired observation count changes visibly.
Read next
- Small multiples: compare groups with honest scales and facet order
- Correlation heatmaps: show pairwise coverage before interpreting color
- Logarithmic axes: disclose zero handling and the linear threshold
- Chart exports: carry the data, filters and render contract together
