Use transformed axes for multiplicative comparisons without silently deleting zeros or negative values.
Logarithmic axes: disclose zero handling and the linear threshold
Distance changes meaning
A linear axis gives equal pixel distance to equal additive differences. A log axis gives equal distance to equal ratios: moving from 8 to 80 occupies the same distance as moving from 80 to 800 at base ten. This can reveal multiplicative growth across orders of magnitude, but it can also disguise an operational change measured in fixed units. Print the axis transformation and ticks prominently. Baseline and scale integrity still matters when the axis no longer has a visually useful zero.
Zero cannot sit on a log axis
The logarithm of zero is undefined, as is the real logarithm of a negative count. A plotting tool may drop these rows, clip them or show a warning. None of those choices should happen silently. Count excluded values before drawing and put that count near the chart. Adding one to every value changes the estimand and can greatly change small counts, so it needs a stated measurement reason rather than being a default repair. For rates, check whether zero reflects a genuine observation or a missing denominator. Denominator policy comes first.
Signed measures need another contract
A symmetric-log scale keeps a linear region around zero and transitions to log-like spacing outside a chosen threshold. It can display positive and negative deviations across a wide range, but the threshold controls the visual emphasis around zero. State its numeric value and show at least the threshold ticks. Alternatively, use separate panels or a linear scale when precise near-zero comparisons matter. Never tell a reader that equal distances have one consistent meaning across the linear and log regions. Comparison panels should share the same threshold.
Test the reading task
Give reviewers two exact questions: which site doubled, and which gained more units? If the axis helps one task but hinders the other, pair it with a table or linear companion view. Annotate omitted nonpositive values and preserve them in the export. Tooltips should report original measurements, not transformed coordinates. The export manifest must record scale type, base, threshold, units and exclusion policy. Test values just below and above the threshold to catch a misleading transition.
Worked contract
from math import isclose, isfinite, log10
def log_axis_values(readings: list[float]) -> tuple[list[float], int]:
if any(not isfinite(reading) for reading in readings):
raise ValueError("non-finite reading")
positive = [reading for reading in readings if reading > 0]
return [log10(reading) for reading in positive], len(readings) - len(positive)
def signed_axis_coordinate(reading: float, threshold: float) -> float:
if not isfinite(reading) or not isfinite(threshold) or threshold <= 0:
raise ValueError("invalid reading or threshold")
magnitude = abs(reading)
mapped = magnitude / threshold if magnitude <= threshold else 1 + log10(magnitude / threshold)
return -mapped if reading < 0 else mapped
positions, omitted = log_axis_values([0, 8, 80, 800])
assert omitted == 1 and isclose(positions[2] - positions[1], 1)
assert signed_axis_coordinate(-47, 1) == -signed_axis_coordinate(47, 1)Performance and operating cost
Mapping N values takes O(N) time and O(N) output space; counting exclusions can be streamed with O(1) additional state. Axis ticks, inverse mapping and renderer behavior add separate costs. The signed mapping is an instructional contract, not a drop-in replacement for a plotting library's symmetric-log formula; choose and document one renderer's exact transform before comparing saved coordinates. Preserve original values for exports and accessible text.
Common Mistakes
- Allowing the renderer to drop zero observations without a visible count.
- Adding one to every count without explaining the changed ratio near zero.
- Comparing panels that use different symmetric-log thresholds.
- Describing distance on a log axis as an additive difference.
Validation drill
Chart 31 sensors ranging from zero to 81,000 units. Answer both multiplicative and additive questions, count all omitted values, and repeat a signed-deviation view with two declared thresholds to show what changes.
