Skip to content
Tutorials Center
My learning

Topics

Lesson 28 of 57 ยท Annotation and Polish

Designing Clear Charts

Make charts people understand at a glance. Learn data-ink, picking the right chart, direct labels, accessible color and before/after redesigns.

Matplotlib will happily draw a chart that is technically correct and impossible to read. Knowing the API is only half the job; the other half is deciding what the reader should notice and removing everything that stands in the way. A clear chart has one message, labels you can read without hunting, and colors that mean something.

This lesson is a set of habits rather than new functions. Every habit is shown as a before-and-after pair so you can see the difference. You already know the tools from Annotations and Arrows, Legends and Grids and Styles, rcParams and Themes; here you decide when to use them.

Five habits of clear charts

One message The title states the finding.
Less ink Remove what carries no data.
Direct labels Name lines where they end.
Purposeful color Color highlights, it does not decorate.

Each habit gets a before and after below.

1 / 2

Start with the message

Before writing any code, finish this sentence: "I want the reader to see that ___." If you cannot, the chart is not ready. The sentence usually becomes the title. A title like "Sales" names the topic; a title like "Mobile sales overtook web in June" states the finding and tells the eye where to look.

Then choose the chart type that fits the question: lines for trends, bars for comparing amounts, scatter plots for relationships, histograms for distributions. Pie charts are rarely the best option because people judge angles poorly; the Pie, Donut and Stacked Area Charts lesson explains when they are acceptable.

Data-ink: remove what does not carry data

Edward Tufte called the share of a chart's ink that shows real data the data-ink ratio. The idea is simple: every box, tick, gridline and color should earn its place. Ask of each element, "would the reader miss this if it were gone?"

Typical candidates to remove or soften:

  • The top and right spines (the frame around the chart).
  • Heavy black gridlines; use light gray or none.
  • Tick marks on both axes when labels already show the values.
  • Redundant labels, such as a y label "Value" on a chart whose title says it all.
  • 3D effects and shadows that distort the data.
Python Before and after: decluttering a bar chart

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The right chart drops the y axis completely because every bar carries its own value. It also sorts the bars, uses one muted color and saves the strong color for the single fact the title mentions. The left chart makes the reader decode five colors that mean nothing.

Hiding the y axis is only fine when you label the values directly. If readers need to estimate values, keep a light axis.

Label directly instead of using a legend

A legend forces the eye to travel back and forth: find the line, find the color in the legend, match the name. Putting the name next to the line removes that step. For line charts, write the label just past the last point and match its color to the line.

Python Before and after: legend versus direct labels

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The trick is set_xlim with some extra room on the right so the text fits inside the Axes. If you have many lines that end close together, direct labels collide; in that case fall back to a legend, or highlight one or two lines and gray out the rest.

Use color with purpose

Color is the strongest tool you have and the easiest to misuse. Three rules cover most cases.

Use gray for context and one strong color for the point. In the examples above, a single saturated color tells the reader where to look. If everything is colored, nothing stands out.

Match color type to data type. Categories (teams, regions) take distinct hues. Ordered numbers take a sequential map such as viridis. Numbers with a meaningful middle (profit and loss) take a diverging map centered on zero. See Colormaps and Color Normalization.

Design for color-vision deficiency. About 1 in 12 men cannot tell some reds from greens. Avoid red versus green as the only difference. Use palettes made for this, and add a second cue, such as line style or direct labels, so the chart still works in grayscale.

Python A palette check: color alone versus color plus shape

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

To test a chart, convert it mentally to grayscale (or print it in black and white). If you can still tell the series apart, the design is robust.

Be honest with scales

A clear chart is also a truthful one. Bars encode value by length, so a bar chart axis must start at zero; a truncated axis makes a small difference look huge. Lines encode change by slope, so a non-zero baseline is acceptable on a line chart if the axis is clearly labeled. Never mix a log scale and a linear scale without saying so, and be careful with two y axes, which can be tuned to suggest any relationship you like (Shared, Twin and Secondary Axes explains the risks).

Python Before and after: a misleading axis

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The left chart shows a 1.3 point gap as if one bar were several times taller. The right one is honest, and the labels still let the reader see the exact numbers. If the small gap really matters, say so in words or show a dot plot, rather than stretching the axis of a bar chart.

Size text for the reader

Text is part of the design. A few guidelines:

  • The title is the largest text, then axis labels, then tick labels, with annotations similar to tick labels.
  • Keep every size at or above about 9 pt in print and 14 pt on slides.
  • Keep text horizontal where you can. If category names are long, use barh instead of rotating them.
  • Left-align the title (loc="left") so it lines up with the axis and reads like a headline.
  • Use plain units in labels ("Revenue (USD millions)"), and format ticks with thousands separators or percent signs (Ticks, Locators and Formatters).

A full redesign

Put the habits together. The starting chart has a default look, a legend, bright colors and a vague title. The redesign has a headline title, two muted lines plus one highlighted line, direct labels and an annotation.

Python Before and after: a full redesign

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Compare what a reader has to do. On the left they must decode four colors, look up a legend and guess what "x" and "y" mean. On the right the title gives the answer, the highlighted line proves it and the annotation marks the moment it happened.

A review checklist

Run through these questions before you publish a chart:

  1. Can you state the message in one sentence, and does the title say it?
  2. Is this the right chart type for the question?
  3. Could anything be deleted without losing information?
  4. Are lines or points labeled directly, or is a legend truly needed?
  5. Is color used for emphasis, and does the chart still work in grayscale?
  6. Do bars start at zero, and are scales labeled?
  7. Is the smallest text still readable at the size it will be shown?

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the best reason to replace a legend with direct labels on a line chart?

    Labels placed at the end of each line remove the back-and-forth lookup, so the chart is read faster and with fewer errors.
  2. 2. Which statement about bar chart axes is correct?

    Bars are compared by length, so cutting off the baseline exaggerates differences. A line chart relies on slope and can use a non-zero baseline if it is labeled.
  3. 3. In the redesigned charts, why are most lines drawn in gray and one in a strong color?

    Muted context plus one strong color guides the eye to the finding, while many equally bright colors compete for attention.
  4. 4. How can you make a multi-line chart readable for people with color-vision deficiency?

    A second cue besides hue means the series stay distinguishable even if some colors look alike, and the Okabe-Ito palette is built to stay distinct.
  5. 5. Which title best follows the "state the finding" rule?

    The third title states the conclusion, so the reader knows what to look for. The others only name the topic.

Summary

  • Start from the message; the title should state the finding, not just the topic.
  • Pick the chart type from the question: lines for time, sorted bars for categories, scatter for relationships, histograms for spread.
  • Remove ink that carries no data: extra spines, heavy grids, rainbow colors and decorations.
  • Label lines and bars directly where you can; use set_xlim to leave room on the right.
  • Use gray for context and one strong color for the point; choose accessible palettes and add shape or line-style cues.
  • Bar charts start at zero; label scales and be careful with dual axes.
  • Keep text large enough for the medium, mostly horizontal, with a left-aligned headline title.

Next: Plotting NumPy and pandas Data