8. Data Visualization
Duration2h30Learning Objectives
Apply:
[BC02] a structured method for turning a data result into a chart that drives a specific decision
[BC02] the point of a data-driven message stated as one actionable sentence, aimed at a named decision-maker
Analyze:
[BC02] why a specific visual element could be removed from a chart without weakening its message
Introduction
Every module so far ends the same way: a table of correlation coefficients, a mean and a standard deviation across folds, a grid of hyperparameter scores. Each is an honest answer to a question you asked yourself — and none of them is something a decision-maker outside the project can act on. This module teaches the four steps that turn a result into a figure someone else can decide from. It draws on Cole Nussbaumer Knaflic’s Storytelling with Data and on IMT Atlantique’s own data storytelling course.
1. Understand the Context
Exploratory analysis is what you have been doing since Session 2: trying things, looking at the data from every angle, following whatever seems interesting. Explanatory analysis is different — you have already found something, and now you need someone else, who was not in the room while you explored, to understand it and act on it. Every module before this one produced a result through exploratory analysis. This module is about the second half of the job.
Three questions frame every explanatory figure, before you touch a chart:
- Who is your audience?
- What do you need them to know or do?
- How will the data help make your point?
Once you know the what, the Big Idea (Nancy Duarte, Resonate, 2010, via Knaflic) turns it into one sentence you can act on. A Big Idea should (1) articulate a point of view, (2) convey what’s at stake, and (3) be a single, complete sentence — imagine having to announce it on social media in one line. “Capacity and demand both vary by month” is an observation, not a Big Idea; “let’s hire seasonal technicians — capacity bottoms out just as demand peaks every summer” is.
Practice this: the notebook’s Step 1 gives you two rival, fully-written Big Ideas for the exact same twelve numbers, for a heating-and-cooling installation & repair company — one about seasonal hiring, one about infrastructure investment. Big Idea #1 is built for you at every step, as a worked example; Big Idea #2 is yours to build the same way, right after.
Recommended reading
The importance of context — the full Who/What/How framework, the Big Idea worksheet, and storyboarding for longer presentations.
2. Choose an Appropriate Visual
A table lets an audience focus on one row or column, but competes for attention during a live presentation. A graph is usually the better default — the challenge is picking the right one for the message, not the prettiest one. Three things to remember: avoid pie charts and anything that asks the eye to compare angles or areas, avoid 3D graphics for the same reason (depth distorts the exact values you are trying to show), and use a single vertical axis with a zero baseline — a second axis or a truncated scale can make an unremarkable difference look dramatic, or hide a real one.
When you are unsure which type fits, build and look at one candidate at a time rather than a wall of subplots side by side — a chart you have not actually looked at carefully is not evidence for or against anything. Two options, in matplotlib and in seaborn/pandas, cover most of what you need here: a line (ax.plot, sns.lineplot) and a filled area (ax.fill_between).
Practice this: the notebook’s default chart is a grouped bar chart — the naive default, unstyled. Neither of the two messages actually needs it: one needs both raw series plotted as lines over the whole year, the other needs neither raw series at all — just their monthly difference, plotted as one line. Choosing the right visual sometimes means computing a new column before you can even draw the chart.
Recommended reading
Choosing an effective visual — the full chart taxonomy. For picking a chart type from scratch: data-to-viz.com and the Tableau Visual Vocabulary.
3. Eliminate Clutter
Clutter is specific, not vague: “borders, gridlines, data markers, and the like” — elements that make an audience do work without adding information. Gestalt psychology explains why removing them can still leave a figure readable: proximity and similarity let elements read as a group without a legend box (a label placed right next to its line does the legend’s job for free); figure-ground is why a clear, prominent title does more for orientation than a border around the plot. Beyond Gestalt, three general habits carry most of the work: don’t be afraid of white space, align elements consistently, and use contrast sparingly enough that it still means something when you need it.
Practice this: the notebook’s Step 3 asks you to change only the habillage of each chart — spines, a framed legend, the raw "2019-01" tick labels rewritten as three letters each (JAN, FEB, …) with the year moved once to the x-axis label — and to ground the figure by moving its title to the left and giving it a bit more size, still saying the same descriptive thing it always did. Color and wording wait for Step 4.
Recommended reading
Clutter is your enemy! — all eight Gestalt principles with examples.
4. Draw Attention Where You Want It
Before choosing any color, check it against the common color-vision deficiencies — David Nichols’ colorblindness simulator, pre-loaded with the IBM Design Library palette, simulates deuteranomaly, protanopia and more in one view, in under two minutes. Don’t assume a default palette passes: matplotlib’s own blue/orange is workable but not the best available, and the IBM palette (#648FFF, #785EF0, #DC267F, #FE6100, #FFB000) measurably improves on it for exactly this pair. This module uses that palette throughout, and never reuses a color across the two Big Ideas’ charts — a color that already means “Demand” in one chart should not silently mean something else in the other.
Preattentive attributes — color, size, position — are processed by the eye before conscious thought, which is what makes them the right tool for directing attention rather than describing everything at once. Grey-plus-accent is the usual move, but it assumes only one series matters at a time; when both series have to stay individually identifiable (as one of this module’s two messages needs), the accent instead becomes a faded-vs-vivid line, paired with filling the area between the two curves — restricted to the specific window of time the message is actually about, not the whole chart.
Practice this: the notebook’s Step 4 checks the default colors against a color-vision-deficiency simulation, switches to the IBM palette, fades each line outside its relevant window and keeps it vivid inside, fills the gap between the two curves there, and marks and labels the specific months that matter — then builds a title whose words are colored to match the series they name, replacing the legend entirely, using a small matplotlib technique (offsetbox.TextArea/HPacker, sometimes called “rainbow text”). Then apply the “close your eyes” test: close your eyes, open them, and check whether the first thing you see is the message.
Recommended reading
Focus your audience’s attention — preattentive attributes in full, and the accessibility section this summary draws from.
Notebook
Files: notebooks/session3/08_data_visualization.ipynb
Open the notebook and select the same .venv kernel as your other notebooks. The whole module works one small dataset — twelve months of capacity vs. demand, one calendar year — twice over: once per message it can tell. Each step is done for the first message, then redone for the second, so the same four moves get applied twice before you are done. Export your two finished charts to reflection/session_3/module_8_BG1.png (Big Idea #1) and reflection/session_3/module_8_BG2.png (Big Idea #2) — you will reference both from your Reflection answer.
Then go further, on air_quality’s own data (data/train.csv, as in Module 1): pick one or more time series — pm2_5 or another satellite variable, totaled or per inhabitant — for one or more cities, and take it through all four steps on your own, no walkthrough this time. There is no single right choice here: decide for yourself who you are (which role or organization you are speaking from), who your audience is, and what you are asking them to fund or decide — then build the Big Idea and the chart that follow from that choice. Export it to reflection/session_3/module_8_BG3.png.
Reflection
Files: reflection/session_3/module_8.md, reflection/session_3/module_8_BG1.png, reflection/session_3/module_8_BG2.png, reflection/session_3/module_8_BG3.png
These questions are about your third chart only — the one built on air_quality’s own data.
Details
Question:
- Who are you in this scenario — what role or organization are you speaking from?
- Who exactly is your audience, and what are you asking them to fund or decide?
- State your Big Idea as a single, complete sentence.
- Justify Steps 2 to 4 for this chart: why that chart type over the alternatives, what you removed at Step 3, and what you focused on at Step 4.