view source

Data Visualization: Chart Types, Colors and Labels

skill

Choose chart types and labels, pick a colorblind-friendly palette and fix misleading graphs. Use when making or reviewing a chart or its colors.

Apache-2.0 Any plotting library. The matplotlib steps need Python with matplotlib, or uv to fetch it; the palette check needs uv or the colour-science package.

agents that use this skill

instructions

Overview

A chart is an argument made with position, length and colour. Use this skill whenever a chart, plot or figure is made, restyled or reviewed, in any plotting library. It decides whether the data needs a chart at all, picks the form by what the reader has to do, gives colour one job, labels the chart so it reads without a legend hunt, and checks it for colour-blind readers and misleading axes. The deliverable is a rendered chart file that was opened and looked at, with its text alternative.

Mental model

  • The reader's task picks the form. People read position on a common scale most accurately, then length; angle, area and colour intensity are read worse (Cleveland and McGill 1984, replicated by Heer and Bostock 2010). Bars, dots and lines beat pies, bubbles and shading whenever values are compared.
  • Colour does one job per chart: identity, order, magnitude, direction from a midpoint, or emphasis. Colour with no job is removed.
  • About 8% of men and 0.5% of women have a colour vision deficiency (Wilke 2019), so colour is never the only carrier: a label, a position or a shape carries the same information.
  • The title states the message and the chart is its evidence.

Rules

Decide whether it is a chart

The data isUseNot
One or two numbersA sentence, or one large figure next to its comparisonA one-bar chart or a two-slice pie
Values the reader looks up one at a time, or exact figuresA tableA chart
A pattern across many valuesA chartA table

Pick the form by the reader's task

TaskFormCondition
Compare categoriesHorizontal bars, largest first; keep a natural order such as age bandsThe bar axis starts at zero
Trend over timeLineThe axis may start above zero; mark a broken axis clearly
DistributionHistogram or box plot
Relationship between two measuresScatter
Share of one wholeSorted bars; a pie only with five slices or fewer and shares near a quarter, a half or three quartersNot a pie when the reader compares close values
Shares of several wholes, or shares over timeStacked barsOnly the bottom segment sits on a common baseline, so put the segment that matters there
Survey answers on an agree-to-disagree scale100% stacked bars; diverging stacked bars when the split around neutral is the messageSegments away from the baseline are hard to compare, so print the values
Before and after per itemTwo dots per row joined by a line, three dots at most
A value over two dimensionsHeatmapSequential scale and a scale legend
Too many series for one panelSmall multiplesEvery panel uses the same axis range
Two measures with different unitsTwo aligned charts, or both indexed to 100 at the startNot a dual axis: where the two scales cross is arbitrary and reads as a relationship

Give colour one job

JobScaleRule
Identity: which seriesQualitativeThree to five colours work best; near eight to ten, matching colours to names fails. Group the tail into "Other" or split into small multiples
Emphasis: one series is the messageOne accent and greyGrey everything first, then give colour back to the series that matters
Magnitude: how muchSequential, one hue from light to dark, or a perceptually uniform map such as viridis or cividisNot rainbow or jet: they add false boundaries, hide detail in the green band and fail colour-blind readers
Direction from a midpointDiverging: two hues and a neutral middleOnly when the midpoint means something (zero, target, average)
Order: stages, tiers, bandsOne hue in stepsThe colour shows the order
One series of unordered categoriesOne colour for every barColouring bars without a purpose adds a variable that is not in the data

Default qualitative palette: Okabe-Ito, in this order for series: #0072B2, #E69F00, #009E73, #D55E00, #CC79A7, #56B4E9, #F0E442, with black #000000 as the eighth. On a white background orange, sky blue and yellow fall below 3:1 contrast, so use them for bars and areas with visible labels, not for thin lines.

  • Grey is for context, "other" and "no data". A category that matters as much as the coloured ones does not get grey.
  • A colour belongs to an entity. Keep the same colour for the same series across every chart of one document.
  • Reserve red and green for bad and good. A series that only happens to be fourth does not wear them.
  • Label text stays in the text colour. A pale series colour fails the 4.5:1 text contrast; put a coloured mark beside the label instead.

Check a custom palette by measurement

A brand palette, or any palette not listed above, is checked with the palette_check.py script listed under Skill Resources, never by eye:

text
uv run --with colour-science python <path>/palette_check.py "#0072B2,#E69F00,#009E73" --surface "#FFFFFF"

It simulates deuteranopia, protanopia and tritanopia and prints the closest pair of colours in each view. No standard sets how far apart chart colours must be, so the floor is the closest pair inside the Okabe-Ito palette. A pair below the floor: change one colour's lightness, or drop a colour. A colour below 3:1 against the surface needs visible labels and values, or an outline. Run it once per background when the chart ships in light and dark.

Labels and text

  • The title says the message ("Signups fell 40% after the April change"). A subtitle says what is measured, where and when. Name the units and the source.
  • Label series directly where they end, and bars at their tip, instead of sending the reader to a legend. Use a legend only when direct labels cannot fit.
  • Label the points the message is about (the end, the extreme, the highlighted series). The axis carries the rest, and exact values for every point belong in a table.
  • A label that does not fit inside its bar moves outside it. Never clip text.
  • Gridlines are few and light. No 3D, no shadows, no decoration that encodes nothing.

Accessibility

  • Short text alternative: chart type, the data, and the reason the chart is there. Don't repeat the title or list every point.
  • Give a data table when the reader is expected to read values, a text description when they are expected to take a message, and both when both.
  • Marks the reader needs in order to understand the chart have 3:1 contrast against what they touch, unless visible labels and values carry the same information. Lines need 3:1 against the background; lines that rarely overlap do not need it against each other.

Build and verify

  1. Look at the data first: type of each variable, number of categories, range, missing values.
  2. State the message in one sentence. If there is none yet, make exploratory charts and say that they are exploratory.
  3. Pick the form, then the colour job, then the labels.
  4. In matplotlib, start from the report.mplstyle file of the analytical-report skill when it is available; pass the Okabe-Ito order explicitly when several series all matter. Run with uv run --with matplotlib python chart.py when matplotlib is not installed.
  5. Save SVG for documents and PNG for chat or slides.
  6. Open the rendered image and look at it: overlapping labels, clipped text, a legend covering data, an axis that exaggerates.

When the user cannot be asked, state the message you assumed the chart should carry.

Examples

Legend hunt to direct message. Bad: "Revenue by region", eight coloured lines, a legend box. Good: "EMEA overtook the Americas in Q3", EMEA in the accent colour, the other regions grey, each line labelled at its right end.

Dual axis to two panels. Bad: signups on the left axis and revenue on the right, crossing in March. Good: two charts stacked on one time axis, or both series indexed to 100 in January on one axis.

Pie to bars. Bad: a pie with nine slices and a legend. Good: horizontal bars sorted by size, the four smallest grouped as "Other", the share printed at each bar's tip.

Checklist

  • A chart is the right answer: not one number, not a look-up table.
  • The form matches the reader's task; bars start at zero; no dual axis.
  • Colour has one job, and the palette is Okabe-Ito, a named sequential or diverging scale, or one that passed the palette check.
  • Three to five colours carry identity where the data allows, eight at most; the tail is grouped or faceted.
  • The title states the message; units and source are named; series are labelled directly.
  • Nothing depends on colour alone; marks have 3:1 contrast or visible labels and values.
  • A text alternative and, where values matter, a data table exist.
  • The rendered file was opened and checked for overlap and clipping.

Composition / References

Scope limits: the statistics behind the numbers, the written report around the chart, and dashboards or interactive chart interfaces are separate jobs.