Field note · May 28, 2024

The category that eats the chart

8 values with 37.9% concentrated in one of them, and what that does to every chart downstream.

1 min read ·Visualization ·visualization practice

country on retail-orders has 8 values, and one of them is 37.9% of the data.

  • US — 2,655 rows, 37.9%
  • GB — 915 rows, 13.1%
  • DE — 738 rows, 10.5%
  • CA — 715 rows, 10.2%
  • JP — 587 rows, 8.4%

The top three take 61.5% between them. The remaining 5 share 38.5%, which is the part that gets rendered as an unreadable stack of slivers if you plot all of them.

sql
select country,
       count(*)                                      as rows,
       round(100.0 * count(*) / sum(count(*)) over (), 1) as pct,
       round(avg(unit_price_usd)::numeric, 2)             as avg_unit_price_usd
from retail_orders
group by 1
order by rows desc;

The second column is the one that matters. Share of rows tells you what is common; avg_unit_price_usd tells you whether the common thing is the important thing. They disagree more often than not, and a chart that shows only the first is answering the easier question.

Decide what happens to the tail before you plot it. "Other" as an explicit bucket is honest; twelve slivers is not, and neither is silently taking the top eight.