Field note · April 7, 2024

The category that eats the chart

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

1 min read ·Visualization ·visualization practice

category on retail-orders has 6 values, and one of them is 24.2% of the data.

  • apparel — 1,696 rows, 24.2%
  • home — 1,279 rows, 18.3%
  • grocery — 1,188 rows, 17.0%
  • beauty — 1,088 rows, 15.5%
  • electronics — 960 rows, 13.7%

The top three take 59.5% between them. With only 6 values there is no tail to worry about, which makes this a genuinely easy column to chart.

sql
select category,
       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.