Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 2.5 — Honest and Misleading Charts
Data Visualization · Example 3 of 3

Totals vs rates, and uneven bins

The left histogram merges everything over 20 minutes into one wide bar, so it looks like the peak. The right one uses equal bins and shows the real peak at 15 to 20 minutes. Dividing each count by its bin width (density) fixes the left one too.

A chart can be built from correct numbers and still mislead: a cut axis on bars, two y axes, circles sized by radius, a hand-picked time window, totals instead of rates, uneven bins, a rainbow colour scale. Learn to spot each one, measure how much it lies, and fix it.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 4 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write lieFactor(shownA, shownB, trueA, trueB) that returns (shown effect ÷ true effect), using effect = (B − A) ÷ A. Return NaN when the true effect is zero. Check it with the June and July example: shown lengths 7,712 and 17,803, true 107,712 and 117,803.

02

A chart shows 12 months of rides with the y axis starting at 40,000. Is that honest for bars? For a line?

Explain it without notes

01

Why must a bar chart start at zero but a line chart need not?

02

What is a lie factor? Compute it for June and July with the axis cut at 100,000.

03

Why can a dual-axis chart mislead even if both axes are labelled?

04

What is wrong with a histogram whose bins have different widths and whose bar height is the count?

Totals vs rates, and uneven bins

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

ranked by total rides: Quay, Lantern, Library, Clock Tower, Mill
ranked by rides per dock: Quay 4882, Mill 3516, Library 3471, Lantern 2905, Clock Tower 1736
a row with 0 docks: 100 rides / 0 = Infinity | 0 rides / 0 = NaN
tallest bar in the unequal chart: 20-55 minutes
tallest by density (count per minute): 15-20 minutes
trips counted: 10000 = 10000