Skip to content

Avoid stacked and overlapping histograms

baddistributionsmechanicalWilke 2019 p. 64Few 2012 p. 135

How does the shape of lunch bills compare with dinner bills?

Plotly Express Tips dataset, lunch (n=68) and dinner (n=176) restaurant bills.

“Stacked histograms are confusing because the upper bars no longer share a common baseline”

Claus O. Wilke, "Fundamentals of Data Visualization", p. 64.

Also covered in Few 2012 (6 FUNDAMENTAL VARIATIONS OF GRAPHS, p. 135).

CVD preview

Before

Stacking lunch bars on top of dinner bars gives lunch a jagged moving baseline so readers cannot judge its peak or spread.

Download before Python code

After

Reflected semi-transparent density curves share the zero baseline and separate lunch and dinner shapes cleanly.

Download after Python code

Values

Lunch checks center around a 15.96 USD median while dinner checks center around 18.39 USD.

Lunch bills concentrate sharply around 13 to 17 USD while dinner bills extend into a wider right tail.

Values used in both charts
ServiceChecksMedian bill (USD)Mean bill (USD)
Lunch6815.9617.17
Dinner17618.3920.8