brokenaxes
raw JSON → 0.6.2 verified Fri May 01 auth: no python
Creates broken axes in matplotlib to plot data with discontinuities or different scales. Current version 0.6.2, release cadence sporadic.
pip install brokenaxes Common errors
error AttributeError: module 'brokenaxes' has no attribute 'brokenaxes' ↓
cause Importing the module instead of the function/class.
fix
Use: from brokenaxes import brokenaxes
error ValueError: xlims must be a list of tuples or a tuple of tuples ↓
cause Passing incorrectly formatted limits, e.g., a single tuple.
fix
Use: xlims=((0,1),(3,4)) — a list/tuple of two or more (min,max) tuples.
Warnings
gotcha brokenaxes modifies global matplotlib style; may affect other plots in same session. ↓
fix Reset matplotlib style after use: matplotlib.style.use('default')
gotcha Auto-tick positioning can place ticks at discontinuities; subplots_advance() call needed to update ticks after plot. ↓
fix Call bax.standardize() after plotting to reposition ticks.
deprecated Parameters like 'd' and 'tilt' are deprecated; use 'diag_color' and 'diag_kwargs' instead. ↓
fix Use diag_color='k' and diag_kwargs={'lw':2} instead of d and tilt.
Imports
- brokenaxes wrong
import brokenaxescorrectfrom brokenaxes import brokenaxes
Quickstart
import matplotlib.pyplot as plt
from brokenaxes import brokenaxes
import numpy as np
fig = plt.figure(figsize=(6, 3))
bax = brokenaxes(xlims=((0, 0.1), (0.4, 0.6)), ylims=((0, 10), (20, 25)), hspace=0.05, wspace=0.05)
x = np.linspace(0, 0.6, 100)
y = 10 * np.sin(50 * x) + 20 * np.sin(5 * x) + 5
bax.plot(x, y)
plt.show()