Loading
0x40Lesson 5 of 10

Choose a useful visualization

Match charts to questions, see why summaries alone can mislead, and avoid charts that distort.

22 min 5-question quiz 2 code exercises
By the end of this lesson you can
  • Pick a chart that matches the comparison you want to show
  • Explain why you must plot data, not just summarize it
  • Avoid common misleading chart designs

Pick the chart from the question:

QuestionChart
How is one numeric variable distributed?histogram, box plot
How do categories compare?bar chart (sorted)
How do two numeric variables relate?scatter plot
How does something change over time?line chart
What share does each part have?bar chart (pies only for 2-3 parts)

In Python, matplotlib and seaborn draw these (df.plot.hist(), df.plot.scatter(x=..., y=...)). The code runner here shows text output, so the exercises draw charts with characters - the thinking is the same.

Try it

Up to 15 XP

Which chart?

Choose the best chart for each question.

0 of 5 sortedScore 0/0
  • “How long do most trips take?”

  • “Which station has the most departures?”

  • “Do longer trips cost more?”

  • “How did daily ridership change over the year?”

  • “Do warmer days have more riders?”

Same statistics, different stories

In 1973 the statistician Francis Anscombe built four small datasets with nearly identical means, variances, correlations and regression lines - and completely different shapes. In 2017 researchers at Autodesk took the idea further with the “Datasaurus Dozen”: a dinosaur and a dozen other drawings, all sharing the same summary statistics. The lesson: always plot your data.

Try it

Up to 15 XP

Anscombe’s quartet

Compare the four rows of statistics. Then reveal the plots.

DatasetMean xMean ySD yCorrelationBest-fit line
I9.007.502.030.82y = 0.50x + 3.00
II9.007.502.030.82y = 0.50x + 3.00
III9.007.502.030.82y = 0.50x + 3.00
IV9.007.502.030.82y = 0.50x + 3.00

Before you look: from the numbers alone, would you guess these datasets look alike?

Key takeaways

  • Histogram for distributions, bars for categories, scatter for relationships, lines for time.

  • Identical summaries can hide completely different data - plot it.

  • Honest charts: labeled axes, bars from zero, no 3-D, enough context.

Lesson quiz

5 questions · pass with 4 correct · up to 50 XP

Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.

Practice: write Python

Write Python in the editor and run it against sample inputs. Python runs locally in your browser using a WebAssembly runtime.

Exercise 1

Build category counts

+25 XP

Read a JSON array of category strings. Print each distinct category and its count in alphabetical order, one per line as category count.

  • Repeated labels
  • One category
main.py
Loading editor…

Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.

Exercise 2

Draw a text histogram

+25 XP

The first line is a bin width; the second a JSON array of numbers. Starting from the bin containing the minimum ((min // width) * width) up to the bin containing the maximum, print each bin as LOW-HIGH | ### (N), where HIGH = LOW + width − 1 and each # is one value.

  • Width 10
  • An empty bin
main.py
Loading editor…

Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…