Labels, scales, legends, and color

3.11.2

Make chart units, series, and numeric ranges easy to interpret.

On this page

Identify each series

Use a title to state the comparison and axis labels to name each measure and unit. Give series readable labels and call legend after drawing them. Add markers or line styles when color alone may be hard to distinguish.

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot([3, 5, 4], marker="o", label="Coffee")
ax.plot([2, 2, 4], marker="s", linestyle="--", label="Tea")
ax.set(title="Daily orders", xlabel="Day index", ylabel="Orders")
ax.legend()
plt.show()
Coffee and tea trend lines use different markers and line styles and appear in a legend. Download image

Choose scales and color maps

Use log scales for positive magnitudes when ratios matter. Values at zero or below do not belong on a standard log axis. Use sequential colors for ordered intensity and a diverging color map when values differ around a meaningful midpoint.

Official references