18

I was mapping a rate per county and the first output used Web Mercator, which visually inflates the northern counties and makes the whole map misleading for anything area-related. It also binned the data into equal-width buckets so 90% of counties fell in one color.

The fix was pinning the projection to Albers USA and forcing a quantile or Jenks classification with a clearly labeled legend, including an explicit color for 'no data'. Suddenly the map told the truth.

Does anyone have a good prompt pattern for making it choose between quantile and Jenks based on the distribution instead of me deciding?

THE PROMPT
Build a US county choropleth with D3 v7 and TopoJSON. Non-negotiables:

Projection: geoAlbersUsa (handles AK/HI insets), never Web Mercator for area-based data. Fit the projection to the container, no hardcoded scale.

Data join: join by 5-digit FIPS as a string (pad leading zeros; a common bug is FIPS 01001 read as 1001). Report how many map features found no data row and how many data rows matched no feature.

Classification: given a values array, pick a scheme by rule - if the distribution is roughly log-normal or highly skewed (|skew| > 1) use quantile (7 classes), else use equal-interval; state which and why. Use a single-hue sequential scheme (ColorBrewer) generated to be colorblind-safe.

Legend: a discrete swatch legend with the actual bin edges as labels (e.g. '12.4 - 18.9'), plus a distinct hatched swatch for 'no data'. Never a continuous gradient bar for a binned map.

Interaction: hover shows county name + raw value + which bin; mobile falls back to tap. Add a one-line caption stating the projection and classification so the map is self-documenting. One HTML file.

2 Answers

13

The FIPS zero-padding note has bitten literally everyone who has made a US map. On the quantile-vs-Jenks question: I have the model compute both, then pick whichever minimizes within-class variance relative to a naive equal-interval baseline, and print the improvement. Jenks usually wins on skewed county rates but not always, so letting the data decide beats a hardcoded choice.

THE PROMPT
Compute equal-interval, quantile, and Jenks (Fisher-Jenks) classifications for 7 classes. Report the goodness-of-variance-fit (GVF) for each and select the highest, but prefer quantile on ties for interpretability. Print the chosen scheme, GVF, and bin edges.
11

One more truth-in-mapping nudge that helped my dashboards: for rate maps, add a reliability layer that greys out counties below a minimum sample size, otherwise a county with 3 people and a 33% rate screams red. I pass a min-denominator and hatch anything under it.

Your Answer