Skip to main content
Albero Academy

Box, Pie & More

Box plots, pie charts, area and error bars — and when each fits.

Core Plot Types9 min

Beyond the big four, Matplotlib offers many specialised charts. Knowing which answers your question is more important than any one syntax.

Box plots

A box plot summarises a distribution's median, quartiles and outliers — ideal for comparing distributions across groups:

ax.boxplot
ax.boxplot([group_a, group_b, group_c], labels=["A", "B", "C"])

Pie, area & error bars

specialised charts
ax.pie(sizes, labels=labels, autopct="%1.1f%%") # part-to-whole
ax.fill_between(x, y_low, y_high, alpha=0.3) # shaded area/range
ax.errorbar(x, y, yerr=errors, fmt="o") # points with uncertainty
ax.stackplot(x, a, b, c, labels=["a","b","c"]) # stacked area

Key takeaways

  1. 01Box plots summarise median, quartiles and outliers — great for comparing distributions.
  2. 02fill_between shades a range/area; errorbar shows uncertainty.
  3. 03stackplot draws stacked areas over a continuous x.
  4. 04Prefer bars over pie charts — angles are hard to compare accurately.

Finished this chapter?

Mark it complete to track your progress through Matplotlib.