axis() convenience

matplotlib’s overloaded axis(): 'equal' fixes a 1:1 aspect ratio, [xmin, xmax, ymin, ymax] sets both limits in one call.

plot 09 axis convenience

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

theta = np.linspace(0, 2 * np.pi, 200)

fig, (ax1, ax2) = plotpress.subplots(1, 2, figsize=(8, 4))
ax1.plot(np.cos(theta), np.sin(theta))
ax1.axis("equal")
ax1.set_title("axis('equal')")

ax2.plot(theta, np.sin(theta))
ax2.axis([0, 3, -0.5, 1.2])
ax2.set_title("axis([xmin, xmax, ymin, ymax])")
fig.tight_layout()

Total running time of the script: (0 minutes 0.092 seconds)

Gallery generated by Sphinx-Gallery