Contents/ Part III · Visualizing Data/ Chapter 17

Choosing the Right Visualization

You now know the charts. This chapter is the decision: given your data and your message, which one? It pulls the last three chapters into a single framework for picking, and refining, the right visual.

⏱️ ~12 min read
🐍 Notebook included
📊 Chapter 17

The most common visualization mistake is starting from the chart. "Let's make a pie" or "put it in a bar chart" puts the tool before the thought. Good chart choice runs the other way: start from what you want the reader to see.

?
Chart choice has two anchors: your message (what relationship do you want to show?) and your data (categorical or numerical, and how many variables?). Pick the chart that serves both.
1

Start With the Message, Not the Chart

Before choosing any chart, ask the question almost no one asks: do you even need a chart?

3️⃣

One or two numbers

Just show the number, big and clearly labeled. A chart of a single value is wasted ink.

Exact values to look up

Use a well-formatted table. Charts are for patterns, not precise read-off.

📈

A pattern or comparison

Now a chart earns its place: shape, comparison, trend, or relationship.

🧭
The one question to ask first

Not "what chart should I make?" but "what do I want the reader to see?" Name that, and the chart almost picks itself.

2

The Chart Chooser: Purpose → Chart

Most charts serve one of five purposes. Name the purpose and you have narrowed hundreds of options to a handful. This is the spine of every chart-chooser (Abela, the FT Visual Vocabulary, the Data Visualization Catalog).

First: do you even need a chart? 1 to 2 numbers → a number · exact values → a table What do you want to SHOW? name the purpose first Comparison Composition Distribution Relationship Trend bar chartdot plot(rank: sort it) stacked bartreemappie (≤5) histogrambox / violindensity scatterbubbleheatmap line chartareaslope then narrow by how many variables / categories you have
PurposeIt answersGo-to chartFrom
Comparison / rankingHow do categories compare? What's the order?Bar (sorted), dot/lollipopCharts for Categorical Data
CompositionWhat are the parts of the whole?Stacked / 100% bar, treemap, pie (≤5)Charts for Categorical Data & Multivariate & Specialized Visuals
DistributionHow are values spread? Outliers? Shape?Histogram, box, violin, densityCharts for Numerical Data
RelationshipDo variables move together?Scatter, bubble, correlation heatmapCharts for Numerical Data & Multivariate & Specialized Visuals
Trend over timeWhat's the trajectory?Line chart, area, slopeCharts for Numerical Data
3

Narrow by Data Type & Variable Count

Once you know the purpose, your data narrows the rest. Cross what kind of variables you have with how many:

1 variable2 variables3+ variables
CategoricalBar of countsGrouped/stacked bar; heatmap of the cross-tabSmall multiples; treemap
NumericalHistogram / box / densityScatter (or line if x is ordered/time)Bubble (size); color + facets
Cat + NumericBar (a value per category)Grouped bar; scatter colored by categoryEncode with color, size, facet
🎚️
Adding variables: spend your channels in order

For three or more variables, add them by perceptual strength: position, then length, then color, then size (see Multivariate & Specialized Visuals). When one chart starts juggling color and size and shape at once, facet into small multiples instead, it keeps the strong position channel in every panel.

4

From Default to Explanatory

The same chart serves two very different jobs, and they call for different polish.

Exploratory (for you)Explanatory (for an audience)
GoalFind what's interestingCommunicate one specific thing
How many chartsMany, fast and roughA few, polished
MessagesManyOne clear takeaway
ColorDefaults are fineSparing: color is the point
🏷️
Title the takeaway, not the axes

The single highest-leverage habit in explanatory work: make the title state the conclusion. "Revenue grew 18% after the April relaunch" beats "Revenue by month." If you want the reader to reach a point, say it in words and let the chart prove it.

A quick checklist to take any default chart from rough to clear, pulling together the Charts for Categorical Data through Multivariate & Specialized Visuals chapters:

Right type, then declutter

Pick the chart for the purpose, then strip gridlines, borders, 3D, and chartjunk.

Focus attention

Gray the context, color the one thing that matters, sort intentionally.

Honest axes & labels

Bars start at zero, lines need not; direct-label over legends; colorblind-safe color.

Say the point

A takeaway title and, where useful, a short annotation on the key value.

🚫
Choice mistakes, not just style mistakes

The costly errors are about the wrong chart for the message: a pie used for ranking (use a bar), a line over unordered categories, dual axes that fake a correlation, 3D that distorts, or a busy chart where a number or table would be clearer. Truncating or cherry-picking the axis is the most consequential of all.

🤖
Why this matters for data science

The same data can tell different stories depending on the chart. Your job is to choose the one that reveals the truth clearly to your audience. This is the hinge between exploratory analysis and communication, the skill that turns a finding into something other people can act on.

5

Choosing the Right Chart in Machine Learning & AI

The same discipline, match the chart to the question, governs a machine-learning workflow. Each stage has a diagnostic plot that is the standard answer, and reaching for the wrong one hides the problem you need to see.

ML questionThe right chartWhat it shows
Is my classifier calibrated and accurate?Confusion matrix and ROC curveWhere predictions go wrong, and the accuracy-versus-coverage trade-off
Is my model under- or over-fitting?Learning curve (a line chart of score vs training size)Whether more data would help, or the model is already saturated
Which features drive the model?Feature-importance bar or a SHAP summaryThe ranked drivers of the prediction, for trust and debugging
🤖
The chart-choice question is always the same

Whether you are exploring a raw dataset or debugging a model, the decision is identical: what is the data type, and what is the question? A time axis wants a line, a category wants a bar, a distribution wants a histogram, and a model's errors want a confusion matrix. The framework transfers whole.

6

Real-World Example: One Dataset, Four Charts

The best way to practice chart choice is on a dataset with several column types. This year of daily coffee-shop metrics has exactly that: a date (a line for the sales trend), a day-of-week category (a bar for the weekend lift, about 254 drinks a weekend day versus 212 on weekdays), and a numeric ticket size (a histogram). The companion notebook draws the right chart for each.

📂 Dataset · choosing-the-right-visualization--coffee_sales.xlsx

One row per day: date (a time axis), day_of_week and top_category (categorical), and drinks_sold and avg_ticket_usd (numeric). The mix of types is the point, each column calls for a different chart.

🐍

Bring it to life in Python

The companion notebook shows one dataset rendered four ways, runs the chooser across four questions, demonstrates when a number or table beats a chart, and makes over a cluttered default into a clean explanatory chart with a takeaway title.

📓 View Notebook (code & outputs) ▶ Open in Colab ⬇ View / Download on GitHub

View opens the rendered notebook instantly (no setup). Open in Colab runs & edits it live in your browser. To run locally, install numpy, pandas, matplotlib and launch jupyter notebook.

🎓 Key Takeaways

  • Start from the message and the data, not the chart; first ask whether you need a chart at all.
  • Name the purpose (comparison, composition, distribution, relationship, trend) and it narrows the choice to a few charts.
  • Cross data type with variable count to land on the specific chart.
  • Exploratory is for you, explanatory is for an audience: the latter needs one takeaway and a conclusion-stating title.
  • Choice mistakes mislead: pie-for-ranking, line over categories, dual axes, 3D, or a chart where a number or table is clearer.
7

Practice Challenges

Five short challenges, beginner to intermediate. Try them on paper or in Python before checking the solutions.

1

Name the chart

For each, name the purpose and the best chart: (a) which of 6 stores sold most; (b) traffic over 24 months; (c) how customer ages are distributed; (d) whether study hours relate to exam scores.

Hint: comparison, trend, distribution, relationship.
2

Bar, not pie

Six teams have resolved-ticket counts. Draw the chart that lets a reader rank them at a glance, and say in one line why a pie would be worse.

Hint: sorted bar; we read length better than angle.
3

Make it explanatory

Monthly defect rates have one bad month. Redraw a plain bar chart so it argues: highlight the problem month, gray the rest, and give it a takeaway title.

Hint: gray context + one amber bar + conclusion-as-title.
4

Exploratory or explanatory?

You are (a) scanning a new dataset for yourself and (b) presenting one finding to executives. How should the charts differ, and what makes a good explanatory title?

Hint: many rough vs few polished; title states the conclusion.
5

Maybe no chart

Pick number, table, or chart for each: (a) a single KPI of 4.6/5; (b) four exact quarterly revenue figures finance will read off; (c) the shape of 10,000 transaction amounts.

Hint: one value → number; precise look-up → table; shape → chart.
Check your work

A fully-worked solutions notebook walks through all five challenges in the same visual style. Try them yourself first, then compare.

📓 View Solutions ▶ Open Solutions in Colab ⬇ View / Download on GitHub
8

Quiz: Test Yourself

Eight quick questions on choosing a visualization. Answer them, hit Check Answers, and keep refining until you score 100%. Your progress is saved, so you can hop back to the chapter and return anytime.