Data Visualization: Chart Types, Colors and Labels
skillChoose chart types and labels, pick a colorblind-friendly palette and fix misleading graphs. Use when making or reviewing a chart or its colors.
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 is | Use | Not |
|---|---|---|
| One or two numbers | A sentence, or one large figure next to its comparison | A one-bar chart or a two-slice pie |
| Values the reader looks up one at a time, or exact figures | A table | A chart |
| A pattern across many values | A chart | A table |
Pick the form by the reader's task
| Task | Form | Condition |
|---|---|---|
| Compare categories | Horizontal bars, largest first; keep a natural order such as age bands | The bar axis starts at zero |
| Trend over time | Line | The axis may start above zero; mark a broken axis clearly |
| Distribution | Histogram or box plot | |
| Relationship between two measures | Scatter | |
| Share of one whole | Sorted bars; a pie only with five slices or fewer and shares near a quarter, a half or three quarters | Not a pie when the reader compares close values |
| Shares of several wholes, or shares over time | Stacked bars | Only the bottom segment sits on a common baseline, so put the segment that matters there |
| Survey answers on an agree-to-disagree scale | 100% stacked bars; diverging stacked bars when the split around neutral is the message | Segments away from the baseline are hard to compare, so print the values |
| Before and after per item | Two dots per row joined by a line, three dots at most | |
| A value over two dimensions | Heatmap | Sequential scale and a scale legend |
| Too many series for one panel | Small multiples | Every panel uses the same axis range |
| Two measures with different units | Two aligned charts, or both indexed to 100 at the start | Not a dual axis: where the two scales cross is arbitrary and reads as a relationship |
Give colour one job
| Job | Scale | Rule |
|---|---|---|
| Identity: which series | Qualitative | Three 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 message | One accent and grey | Grey everything first, then give colour back to the series that matters |
| Magnitude: how much | Sequential, one hue from light to dark, or a perceptually uniform map such as viridis or cividis | Not rainbow or jet: they add false boundaries, hide detail in the green band and fail colour-blind readers |
| Direction from a midpoint | Diverging: two hues and a neutral middle | Only when the midpoint means something (zero, target, average) |
| Order: stages, tiers, bands | One hue in steps | The colour shows the order |
| One series of unordered categories | One colour for every bar | Colouring 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:
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
- Look at the data first: type of each variable, number of categories, range, missing values.
- State the message in one sentence. If there is none yet, make exploratory charts and say that they are exploratory.
- Pick the form, then the colour job, then the labels.
- In matplotlib, start from the
report.mplstylefile of theanalytical-reportskill when it is available; pass the Okabe-Ito order explicitly when several series all matter. Run withuv run --with matplotlib python chart.pywhen matplotlib is not installed. - Save SVG for documents and PNG for chat or slides.
- 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.
- Heer and Bostock, "Crowdsourcing Graphical Perception", CHI 2010: https://vis.stanford.edu/files/2010-MTurk-CHI.pdf
- Few, "Show Me the Numbers", 2nd ed. 2012, ch. 3 (tables versus graphs); "Save the Pies for Dessert", 2007: https://www.perceptualedge.com/articles/visual_business_intelligence/save_the_pies_for_dessert.pdf ; "Dual-Scaled Axes in Graphs", 2008: https://www.perceptualedge.com/articles/visual_business_intelligence/dual-scaled_axes.pdf
- Wilke, "Fundamentals of Data Visualization", 2019: https://clauswilke.com/dataviz/color-pitfalls.html , https://clauswilke.com/dataviz/redundant-coding.html , https://clauswilke.com/dataviz/multi-panel-figures.html
- UK Government Analysis Function, "Data visualisation: charts": https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-charts/
- Datawrapper: https://www.datawrapper.de/academy/what-to-consider-when-creating-a-pie-chart , https://www.datawrapper.de/academy/why-our-column-and-bar-charts-start-at-zero , https://www.datawrapper.de/blog/dualaxis/ , https://www.datawrapper.de/blog/stacked-column-charts , https://www.datawrapper.de/blog/divergingbars , https://www.datawrapper.de/blog/emphasize-with-color-in-data-visualizations , https://www.datawrapper.de/academy/how-to-create-a-dot-plot
- Heiberger and Robbins, "Design of Diverging Stacked Bar Charts for Likert Scales", 2014: https://www.jstatsoft.org/article/view/v057i05
- Okabe and Ito, "Color Universal Design", 2008: https://jfly.uni-koeln.de/color/ ; ColorBrewer: https://colorbrewer2.org/
- Crameri, Shephard and Heron, "The misuse of colour in science communication", 2020: https://www.nature.com/articles/s41467-020-19160-7
- Machado, Oliveira and Fernandes, colour vision deficiency simulation, 2009: https://www.inf.ufrgs.br/~oliveira/pubs_files/CVD_Simulation/CVD_Simulation.html
- WCAG 2.2: https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html , https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html , https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html
- W3C complex images tutorial: https://www.w3.org/WAI/tutorials/images/complex/ ; Cesal, "Writing Alt Text for Data Visualization": https://nightingaledvs.com/writing-alt-text-for-data-visualization