Note
Go to the end to download the full example code.
Subplot grid
Four fully independent axes on one figure – no global state.

Live figure — pick a tool, then zoom, pan, point-pick or annotate. Nothing is active until a tool is selected.
View this figure’s Vega export ↗ — the raw JSON spec, rendered live by a real Vega engine.
View this figure’s Vega-Lite export ↗ — the raw JSON spec(s), rendered live by a real Vega-Lite engine.
import numpy as np
import plotpress
x = np.linspace(0, 10, 200)
fig, axes = plotpress.subplots(2, 2, figsize=(8, 6))
axes[0, 0].plot(x, np.sin(x)); axes[0, 0].set_title("sin")
axes[0, 1].plot(x, np.sqrt(x), color="#d62728"); axes[0, 1].set_title("sqrt")
axes[1, 0].scatter(x, np.sin(x), s=6); axes[1, 0].set_title("scatter")
axes[1, 1].pcolormesh(np.outer(np.sin(x[:40]), np.cos(x[:40])), cmap="plasma")
axes[1, 1].set_title("mesh")
fig.suptitle("Subplot grid"); fig.tight_layout()
Total running time of the script: (0 minutes 0.174 seconds)