Definition
A logarithmic axis is a plot axis on which the distance between two positive values is proportional to the logarithm of their ratio; the base-10 logarithm of a number is the power to which 10 must be raised to give that number. Equal ratios therefore take equal lengths: 1 to 10 is as long as 10 to 100. A multiplicative difference between two positive values is their ratio, as in “twice as long”, not their subtraction, as in “5 milliseconds longer”. A logarithmic axis shows multiplicative differences as distances.
Where it fits
Main entry: Matplotlib (§12.30).
The Matplotlib entry shows how a plotting program draws a logarithmic axis; this entry is about reading one. Write for the base-10 logarithm. The value 1 sits at position , 10 at , 100 at 2 and 1000 at 3, so the powers of 10 are evenly spaced. The stretch from one power of 10 to the next is called a decade. Inside a decade the gridlines crowd toward the upper end: 2 lies of the way from 1 to 10, and 5 lies of the way. Changing to another base multiplies every position by the same constant, so the change turns no straight line into a curve.
A straight line stands for a different law on each kind of plot. Let be the value on the horizontal axis, the value on the vertical axis, and , , and constants.
Both axes linear: . Each step of 1 in adds to . This is linear growth.
Vertical axis logarithmic, horizontal axis linear, called a semi-log plot: , so . Each step of 1 in multiplies by . This is exponential growth.
Both axes logarithmic, called a log-log plot: , so , a power law whose exponent is the slope of the line. Multiplying by 10 multiplies by . Only slope 1 gives , growth in proportion to .
Horizontal axis logarithmic, vertical axis linear: . Each tenfold increase of adds to . This is logarithmic growth.
Let be a latency in milliseconds and the number of items an operation processes. On a log-log plot, gives , 100 and 10000 at , 10 and 100. These points are drawn at , and , on a straight line of slope . Linear growth with a fixed starting cost, by contrast, bends on a log-log plot. For , the values at , 10 and 100 are 7, 25 and 205, drawn at horizontal positions 0, 1 and 2 and at heights of about 0.845, 1.398 and 2.312. The slope is between the first two points and between the last two: a curve that approaches slope 1 only where the 5-millisecond starting cost becomes small next to .
Vertical distances on a logarithmic axis are ratios. Two curves a constant distance apart differ by a constant factor: a distance of decades everywhere means that one curve is everywhere twice the other. The same additive difference looks large low on the axis and small high on it: 1 to 2 milliseconds spans decades, 100 to 101 milliseconds only decades. For an additive difference, read both values off the axis and subtract.
Limits and common mistakes
A logarithm exists only for positive numbers. A latency of 0, which a coarse timer can record, cannot be placed on a logarithmic axis; plotting programs drop such points or move them to the edge of the plot, often without a warning. A symmetric logarithmic scale, which is linear in a band around 0, shows ratios only outside that band.
A few points on a line do not establish a law. Over less than one decade, a power law, an exponential and a straight line with a starting cost can all look straight; telling them apart needs data that span several decades. A fitted line also says nothing about why the values grow.
The steepness seen on the page depends on the width and height of the plot. Compute a slope from the axis values, as in the examples above, not from the angle of the line on the page, and only after checking which axes are logarithmic.
Questions answered
Does a straight line on this plot imply linear latency growth?
Not in general: a straight line shows linear latency growth on a plot whose two axes are both linear, and on a plot whose two axes are both logarithmic only when the slope of the line is exactly 1. Latency is the time from the start of an operation to its completion. On a logarithmic axis, equal distances stand for equal ratios, not equal amounts.
If only the latency axis is logarithmic, a straight line means that latency is multiplied by the same factor at each step along the horizontal axis, which is exponential growth: latencies of 1, 10 and 100 milliseconds at steps 0, 1 and 2 are drawn at heights 0, 1 and 2 and lie on a straight line, yet they grow by and then by milliseconds. If both axes are logarithmic, a straight line of slope means that latency is proportional to the -th power of the horizontal value: with slope 2, ten times the input gives times the latency. On such a plot, growth with a fixed starting cost, such as 5 milliseconds plus 2 milliseconds per item, appears as a curve. Read the tick labels first: 1, 10, 100 at equal spacing mark a logarithmic axis.
Related entries: Estimand and estimator (§11.2), Sensitivity analysis (§11.46), Figure 7 left: continuity as three ECDFs on a log axis (§18.2.8), Geometric mean (§11.39), Contrast, normalization, ratio, and percent overhead (§18.1.13).