Skip to content
Tutorials Center
My learning

Topics

Lesson 28 of 76 ยท Visualization and Storytelling

Principles of Effective Visualization

Choose the right chart, use position and length for accuracy, pick accessible colors, remove clutter, label directly and avoid misleading axes, with live before/after charts.

A chart is an argument made with shapes. When it works, a reader sees the answer in a few seconds without reading a single number. When it fails, the reader is left decoding a legend, squinting at similar colors, or worse, believing something the data does not say. Exploration charts only have to help you; the charts in a report must help someone who was not there while you worked.

This lesson is about the decisions behind a good chart rather than the code that draws it. Which chart type fits the question? Which visual properties can people judge accurately? How should color be used so that it still works for readers with color-vision deficiency? What can you delete? And how do charts mislead, even when every number is correct? The examples use matplotlib, which you will study more closely in Matplotlib for Analysts; for a first introduction see the Python lesson on matplotlib.

Start with the question, then the chart type

Do not start with "what chart should I make?". Start with "what do I want the reader to compare or notice?". Most business questions fall into a handful of families, and each family has a default chart.

flowchart TD
    Q["What is the question?"] --> A["Compare categories"]
    Q --> B["Change over time"]
    Q --> C["Distribution of one variable"]
    Q --> D["Relationship between two variables"]
    Q --> E["Parts of a whole"]
    A --> A1["Bar chart<br/>(sorted)"]
    B --> B1["Line chart"]
    C --> C1["Histogram, box plot, ECDF"]
    D --> D1["Scatter plot"]
    E --> E1["Stacked bar, or a table"]

A first choice of chart type follows from the question you ask the data.

A few rules of thumb come out of this map:

  • Categories go in a bar chart, sorted by value unless the categories have a natural order (months, age groups). Long labels read best on a horizontal bar chart.
  • Time goes on the horizontal axis of a line chart. Lines suggest continuity, so do not use them for unordered categories.
  • Distributions need a histogram, box plot or ECDF; a single average hides the shape. The next lessons on univariate analysis and uncertainty go further.
  • Relationships between two numeric variables belong in a scatter plot.
  • Parts of a whole are hard to read. A pie chart is acceptable only for two or three slices; beyond that, a sorted bar chart is almost always clearer.

What people can judge accurately

Visual encodings are not equally easy to read. Research on perception, going back to Cleveland and McGill, ranks them roughly like this, from most to least accurate:

  1. Position along a common scale (dots, bars starting at the same baseline)
  2. Length (bars)
  3. Angle and slope
  4. Area
  5. Color intensity and hue

That is why a bar chart beats a pie chart for comparing five values: the eye compares bar ends against a shared baseline, but has to estimate angles and areas in a pie. The next example draws the same data both ways.

Python The same numbers as a pie and as a sorted 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.

In the pie it is hard to say whether North or East is larger, or by how much. In the sorted bars, the ranking and the gaps are obvious, and the printed values remove any doubt.

The axis must tell the truth

The most common way a correct chart misleads is the axis. Two cases matter.

Bar charts must start at zero. The length of a bar is the data. If you cut off the bottom, you cut away part of the quantity and exaggerate every difference. A bar twice as tall must mean twice the value.

Line and scatter charts do not need zero. Their position encodes the value, not the length, so a tight axis can be fine (a temperature chart does not need to start at 0 degrees). Choose a range that shows the real variation, but not one that turns noise into drama.

Two other tricks to watch for are a dual axis with unrelated scales (you can make two lines appear to correlate by stretching one) and a time axis with uneven spacing. The following example shows the first problem, using a difference of one percentage point.

Python Truncated axis vs honest 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.

On the left, Plan B looks several times better. On the right, the two bars are nearly the same, which is the truth for a one-point difference (and whether it is a real difference at all is a question for hypothesis testing).

Warning: If a chart can only be made to look dramatic by cutting the axis, the honest conclusion is that the difference is small. Say so in the title instead of in the axis.

Use color with purpose

Color is the weakest accurate encoding, but it is great for two jobs: separating a few categories and highlighting one thing. Follow these habits:

  • Use few colors. Beyond five or six, readers cannot match legend entries to lines. Group categories or use small multiples (see the next lesson).
  • Grey out the background. Draw the context in light grey and the one series you talk about in a strong color.
  • Do not rely on color alone. About 1 in 12 men and 1 in 200 women have some form of color-vision deficiency. Red and green are the classic problem pair. Add direct labels, line styles or markers.
  • Pick a color-blind-safe palette. The Okabe-Ito colors were designed for this. Blue (#0072B2), orange (#E69F00) and vermillion (#D55E00) are distinguishable for almost everyone.
  • Match the color scale to the data. Use a sequential scale (light to dark) for values that go from low to high, and a diverging scale (two hues meeting at a neutral midpoint) only when there is a meaningful center such as zero or an average.
  • Check contrast. Light grey text on white may look elegant on your monitor and vanish on a projector.

Reduce clutter, label directly

Edward Tufte called the share of ink that shows data the data-ink ratio. You do not need to follow the idea to the letter, but the instinct is sound: every element should earn its place. Heavy borders, gridlines in dark colors, 3D effects, drop shadows and rainbow fills compete with the data.

Good habits:

  • Remove the top and right spines, and keep only light gridlines (or none if values are printed).
  • Replace the legend with direct labels at the end of each line. The reader's eye stays on the data.
  • Write a title that states the finding ("Support tickets doubled after the March release") instead of the topic ("Tickets by month").
  • Always label axes with units. A value without a unit is a riddle.
  • Put the source and the date range in a small note.
Python Cluttered chart vs a clean one with 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.

Both charts contain the same numbers. The right one lets you read the story without a legend, and the title tells you what to look for.

A short checklist

Before you share a chart, ask:

  1. Does the chart type match the question?
  2. Do bars start at zero, and do axes have labels and units?
  3. Is the title a statement of the finding?
  4. Could someone with color-vision deficiency still read it? Would it survive a black-and-white print?
  5. Is there anything I can remove without losing information?
  6. Would the chart still make sense if I were not there to explain it?

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which encoding do people judge most accurately?

    Position along a shared baseline is the most precise visual comparison, which is why dot plots and bar charts work so well.
  2. 2. Why must a bar chart start its value axis at zero?

    A bar's length is the quantity. A truncated baseline makes small differences look large. Line charts encode value by position and can use a tighter range.
  3. 3. What is the best replacement for a legend on a line chart with a few series?

    Direct labels keep the reader's eyes on the data and remove the matching step between legend and line.
  4. 4. Which title is best for a chart in a report?

    A title that states the finding tells readers what to look for. The other titles describe the chart, not the message.
  5. 5. A chart uses red for 'bad' and green for 'good' with no other cue. What is the problem?

    Red-green color-vision deficiency is common. Use other cues (labels, markers, position) or a palette such as Okabe-Ito.

Summary

  • Start from the question; each question family has a default chart (bars for categories, lines for time, histograms for distributions, scatter plots for relationships).
  • Position and length are read accurately; area, angle and color are not. Prefer sorted bars to pies.
  • Bar charts start at zero. Do not use truncated or dual axes to make small differences look big.
  • Use few colors, highlight one series in a strong color, grey out the rest, and never rely on color alone.
  • Remove clutter, label lines directly, state the finding in the title, and always show units and sources.

Next: Matplotlib for Analysts, the tool for building these charts in code.