0
0
Matplotlibdata~3 mins

Why Broken axes concept in Matplotlib? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

See how a simple break in the axis can reveal hidden stories in your data!

The Scenario

Imagine you have a graph showing sales data where most values are small, but a few are extremely large. Trying to fit all data on one scale makes the small values look squished and unreadable.

The Problem

Manually adjusting the scale or cutting out parts of the axis means losing important details or confusing the viewer. It's slow to tweak and easy to make mistakes that hide the real story in the data.

The Solution

The broken axes concept lets you split the axis into parts with a visible break. This way, you can show small and large values clearly on the same plot without distortion or confusion.

Before vs After
Before
plt.plot(data)
plt.ylim(0, max(data))  # all data squeezed
After
from brokenaxes import brokenaxes
bax = brokenaxes(ylims=((0, 10), (90, 100)))
bax.plot(range(len(data)), data)
What It Enables

It enables clear visualization of data with very different scales in one easy-to-understand graph.

Real Life Example

Showing monthly expenses where most months are under $1000 but one month has a $10,000 emergency expense, all visible in one chart.

Key Takeaways

Manual axis scaling can hide important data details.

Broken axes split the axis to show different ranges clearly.

This makes complex data easier to understand at a glance.