Legend

noun

say it: “LEJ-und” /ˈlɛdʒənd/

The small box on a chart that shows which color or line style stands for which group.

What is a chart's legend?

A legend is a chart's small key: it names each line or set of bars beside a sample of its color and style, so the reader knows which is which. In matplotlib, give each line a label= and call ax.legend(). A chart with one line doesn't need one.

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(["Jan", "Feb", "Mar"], [42, 45, 51], label="Paper")
ax.plot(["Jan", "Feb", "Mar"], [18, 17, 20], label="Plastic")
ax.legend()

In a sentence

  • “With only one line on the chart, she left the legend off.”
  • “The legend showed blue for paper and orange for plastic.”

Level: Apprentice · More Python terms at this level

Updated