A chart that makes the point
Decide what a chart is for, write a title that says it, make four edits that do most of the work, show the data when you can, and use the note for the fine print.
What runs in CodeSplash
- Two-sample t-test (Welch / Student, or z test) Verified in Python and R
You will be able to
- Tell a chart for exploring from a chart for explaining
- Write a title that states the finding when the venue allows it
- Edit a chart so that one point stands out, and note what a reader needs
Read first
Exploring isn't explaining
ReadYou made dozens of charts while you worked, to find things out. Those were for you, so a default title and a legend were fine.
A chart in a report has a different job. It's there to show someone else one thing you found, and they weren't with you when you found it.
So before you polish anything, finish this sentence: "This chart shows that…". If you can't, it isn't ready to be shared. If you need "and" twice, it's probably two charts.
Which title?
PredictPredict first
A chart goes in an executive summary. Which title is most useful there?
Reveal
The third. It's an action titleAction titleA chart or slide title that states the finding, so that the reader knows what to see and can check it.: it tells a reader what to see, and they can check it against the picture. For a journal, follow its style. APA figure titles describe the content, so the finding goes in your text.
Find the one point
ExploreThis chart shows each group's observations and, on its own axis, the difference between them with its interval.
View data
| length | supplement | difference | diff low | diff high |
|---|---|---|---|---|
| 26.800 | VC | 2.123 | −2.152 | 6.398 |
| 4.900 | VC | 2.123 | −2.152 | 6.398 |
| 21.900 | VC | 2.123 | −2.152 | 6.398 |
| 30.500 | VC | 2.123 | −2.152 | 6.398 |
| 12.200 | VC | 2.123 | −2.152 | 6.398 |
| 30.700 | VC | 2.123 | −2.152 | 6.398 |
| 28.100 | VC | 2.123 | −2.152 | 6.398 |
| 7.600 | VC | 2.123 | −2.152 | 6.398 |
| 3.300 | VC | 2.123 | −2.152 | 6.398 |
| 19 | VC | 2.123 | −2.152 | 6.398 |
| 29.800 | VC | 2.123 | −2.152 | 6.398 |
| 33.500 | VC | 2.123 | −2.152 | 6.398 |
| 8 | VC | 2.123 | −2.152 | 6.398 |
| 12.700 | VC | 2.123 | −2.152 | 6.398 |
| 33.100 | VC | 2.123 | −2.152 | 6.398 |
| 20.200 | VC | 2.123 | −2.152 | 6.398 |
| 18.200 | VC | 2.123 | −2.152 | 6.398 |
| 20.300 | VC | 2.123 | −2.152 | 6.398 |
| 23.400 | VC | 2.123 | −2.152 | 6.398 |
| 26.800 | VC | 2.123 | −2.152 | 6.398 |
| 29.700 | VC | 2.123 | −2.152 | 6.398 |
| 18.800 | VC | 2.123 | −2.152 | 6.398 |
| 27 | VC | 2.123 | −2.152 | 6.398 |
| 11.300 | VC | 2.123 | −2.152 | 6.398 |
| 17.200 | VC | 2.123 | −2.152 | 6.398 |
| 14.500 | VC | 2.123 | −2.152 | 6.398 |
| 9.700 | VC | 2.123 | −2.152 | 6.398 |
| 17.200 | VC | 2.123 | −2.152 | 6.398 |
| 14.100 | VC | 2.123 | −2.152 | 6.398 |
| 14.100 | VC | 2.123 | −2.152 | 6.398 |
| 16.300 | OJ | 2.123 | −2.152 | 6.398 |
| 14.400 | OJ | 2.123 | −2.152 | 6.398 |
| 31.600 | OJ | 2.123 | −2.152 | 6.398 |
| 25.300 | OJ | 2.123 | −2.152 | 6.398 |
| 17.600 | OJ | 2.123 | −2.152 | 6.398 |
| 21.300 | OJ | 2.123 | −2.152 | 6.398 |
| 17.400 | OJ | 2.123 | −2.152 | 6.398 |
| 10.200 | OJ | 2.123 | −2.152 | 6.398 |
| 38.500 | OJ | 2.123 | −2.152 | 6.398 |
| 12.100 | OJ | 2.123 | −2.152 | 6.398 |
| 5.400 | OJ | 2.123 | −2.152 | 6.398 |
| 21.600 | OJ | 2.123 | −2.152 | 6.398 |
| 20.700 | OJ | 2.123 | −2.152 | 6.398 |
| 22.700 | OJ | 2.123 | −2.152 | 6.398 |
| 22.200 | OJ | 2.123 | −2.152 | 6.398 |
| 16.300 | OJ | 2.123 | −2.152 | 6.398 |
| 27.200 | OJ | 2.123 | −2.152 | 6.398 |
| 17.800 | OJ | 2.123 | −2.152 | 6.398 |
| 20.300 | OJ | 2.123 | −2.152 | 6.398 |
| 24.500 | OJ | 2.123 | −2.152 | 6.398 |
| 32.900 | OJ | 2.123 | −2.152 | 6.398 |
| 24.300 | OJ | 2.123 | −2.152 | 6.398 |
| 4.400 | OJ | 2.123 | −2.152 | 6.398 |
| 19.500 | OJ | 2.123 | −2.152 | 6.398 |
| 29 | OJ | 2.123 | −2.152 | 6.398 |
| 19 | OJ | 2.123 | −2.152 | 6.398 |
| 22.500 | OJ | 2.123 | −2.152 | 6.398 |
| 38.500 | OJ | 2.123 | −2.152 | 6.398 |
| 26.400 | OJ | 2.123 | −2.152 | 6.398 |
| 28.400 | OJ | 2.123 | −2.152 | 6.398 |
Is your point that the groups overlap, or the size of the gap? Both are here, and each suggests a different title. Say which you mean. Then open the chart in Charts and read its How to read tab to see whether a reader would find it unaided.
Four edits that do most of the work
Read- Order categories by value, unless they have a natural order.
- Label things directly, next to the line or bar, so nobody has to look back and forth to a legend.
- Highlight one thing. Mute everything else to a quiet gray, and spend your color on the point.
- Cut what carries nothing: heavy gridlines, repeated labels, and 3D.
View data
| product | revenue |
|---|---|
| Routers | 174.90 |
| Cables | 15.420 |
| Chargers | 25.680 |
| Cameras | 634.51 |
| Speakers | 134.27 |
| Phones | 427.04 |
| Chargers | 14.110 |
| Cables | 20.470 |
| Headphones | 367.94 |
| Routers | 166.60 |
| Cables | 10.800 |
| Cables | 13.520 |
| Printers | 291.17 |
| Laptops | 1422.50 |
| Watches | 364.38 |
| Speakers | 163.27 |
| Chargers | 39.510 |
| Keyboards | 93.420 |
| Phones | 709.95 |
| Cables | 9.830 |
| Cables | 38 |
| Phones | 892.99 |
| Cables | 14.540 |
| Laptops | 1326.02 |
| Printers | 286.51 |
| Keyboards | 100.27 |
| Chargers | 34.410 |
| Monitors | 309.54 |
| Cables | 16.720 |
| Laptops | 1431.28 |
| Cables | 17.480 |
| Tablets | 572.75 |
| Laptops | 1638.78 |
| Phones | 1347.67 |
| Drives | 101.94 |
| Chargers | 28.160 |
| Cables | 17.350 |
| Chargers | 31 |
| Drives | 117.61 |
| Cables | 13.800 |
| Chargers | 37.350 |
| Cables | 13.810 |
| Laptops | 1844.74 |
| Cables | 10.840 |
| Chargers | 41.680 |
| Cables | 29.340 |
| Headphones | 182.94 |
| Headphones | 259.47 |
| Phones | 1109.36 |
| Chargers | 32.690 |
| Phones | 771 |
| Headphones | 289.72 |
| Keyboards | 203.65 |
| Printers | 348.41 |
| Tablets | 568.91 |
| Tablets | 621.64 |
| Monitors | 307.55 |
| Headphones | 128.50 |
| Keyboards | 53.630 |
| Monitors | 244.66 |
First 60 of 1500 rows.
Ranked bars in Charts comes sorted and labeled.
Show the data when you can
ExploreSummaries can hide a lot. These datasets have the same means, spreads and correlation, and they look nothing alike.
CExplorable · Same statistics, different pictures
How can datasets with identical summaries look nothing alike?
As the cloud morphs into this shape, what happens to Pearson's r?
Target
Mean, SD and correlation are held fixed along the way.
| Mean of x | SD of y | Pearson r | Spearman ρ |
|---|---|---|---|
| 54.30 | 26.90 | −0.060 | −0.029 |
Commit your prediction above to see the result
Make your prediction to see the result.
With tens of points per group, a bar for each mean throws away most of what you know. Strip plot with mean ± CI or Raincloud in Charts keeps the points and still shows the summary.
Keep the bars for counts and totals, where the length is the quantity.
Send it to a report
In the appOpen Charts, choose a chart, and press Use my data to bind it to your columns. Then use Send to report or dashboard to add it to a report.
In the report, fill in Title with your sentence. Figures are numbered for you. Then read your report's preview: could someone who wasn't there say what the chart shows?
The note carries the fine print
ReadThe title says what to see, and the Note field says how to read it. Put these there:
- What any bars or bands show: SD, SE or a 95% CI.
- How many observations each group has.
- Anything excluded, and where the data come from.
Without the note, error bars can't be read at all, and a reader can't tell a sample of 12 from one of 12,000.
Do it in code
ExploreThe Code tab in Charts writes your chart in matplotlib, plotly or ggplot2. Here are the edits by hand: a sentence for a title, the observations in gray, and the means labeled directly.
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv("toothgrowth.csv")
fig, ax = plt.subplots()
for i, (name, g) in enumerate(df.groupby("supp")):
ax.scatter([i] * len(g), g["len"], alpha=0.4, color="#888888")
m = g["len"].mean()
ax.hlines(m, i - 0.2, i + 0.2, color="#2a6fdb", linewidth=3)
ax.text(i + 0.23, m, f"mean {m:.1f}", va="center")
ax.set_xticks([0, 1], ["Orange juice", "Ascorbic acid"])
ax.set_xlim(-0.5, 1.8)
ax.set_ylabel("Tooth length")
ax.set_title("Orange juice gave longer teeth on average, but the groups overlap", loc="left")
ax.spines[["top", "right"]].set_visible(False)
plt.show()library(ggplot2)
df <- read.csv("toothgrowth.csv")
means <- aggregate(len ~ supp, df, mean)
ggplot(df, aes(supp, len)) +
geom_point(color = "#888888", alpha = 0.4) +
geom_crossbar(data = means, aes(ymin = len, ymax = len), width = 0.4, color = "#2a6fdb") +
geom_text(data = means, aes(label = sprintf("mean %.1f", len)), nudge_x = 0.33) +
scale_x_discrete(labels = c(OJ = "Orange juice", VC = "Ascorbic acid")) +
labs(title = "Orange juice gave longer teeth on average, but the groups overlap", x = NULL, y = "Tooth length") +
theme_minimal()Check your understanding
CheckpointCheck yourself
Which is an action title?
Show the answer
Answer: b
It states the finding, which a reader can then check against the chart. Use one only if the data support it, and if the venue allows it.
Check yourself
A line chart has five lines and a legend in the corner. What's the most useful edit?
Show the answer
Answer: a
Direct labels end the back-and-forth with a legend, and highlighting tells the reader where to look.
Check yourself
Where should "error bars show 95% confidence intervals; n = 30 per group" go?
Show the answer
Answer: b
Error bars look the same whatever they show, so the chart can't be read without this.
Your next chart
ReflectTake a chart you're about to share and write its point as one sentence. Does the chart make that obvious? Which of the four edits would help the most?
Recap
Recap- A chart in a report has one job, so finish the sentence "This chart shows that…".
- Use a title that says it if the venue allows, and make the four edits.
- Show the data where you can, and put the fine print in the note.
Concepts in this lesson