Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 13.3 — Choropleths and Symbol Maps
Data Visualization · Example 1 of 3

Districts coloured by total and by rides per dock

Ardenvale has no population data, so the rate is rides per dock. A map that shows a count and a map that shows a rate are two different answers.

A choropleth colours each area by a value, and a symbol map puts a circle on each place. Both are easy to draw and easy to get wrong: totals follow size, classes decide the colours, a circle's area (not its radius) must show the value, and zoom must not grow the symbols.

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

Add a legend to the choropleth: four squares with the class ranges (scale.thresholds() gives the breaks of a quantize scale).

02

Write circleRadius(value, max, maxRadius) that returns 0 for missing, zero or negative values, and a square-root scaled radius otherwise.

Explain it without notes

01

Why is a choropleth of total rides less useful than one of rides per dock?

02

How do quantize, quantile and threshold scales differ, and when does each mislead?

03

Why must a circle's radius be the square root of the value?

04

How do you stop circles growing when the map zooms?

Districts coloured by total and by rides per dock

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

district    |    rides | docks | per dock | class by total | class per dock
Harbour     |   247823 |    84 |     2950 |              4 |              4
Old Town    |   237979 |   106 |     2245 |              4 |              3
University  |   149867 |    88 |     1703 |              3 |              2
Riverside   |   135790 |    78 |     1741 |              2 |              2
Hillcrest   |   116649 |    76 |     1535 |              2 |              2
Westpark    |    45543 |    52 |      876 |              1 |              1
Busiest district against the quietest: total 5.4x, per dock 3.4x
all six equal: every district is class 4 | a missing value: no data | NaN: no data
quantile classes (about equal counts): 4 4 2 3 1 1 | quantize classes: 4 3 2 2 2 1