Note
Go to the end to download the full example code.
Axline

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
rng = np.random.default_rng(3)
x = np.linspace(0, 10, 60)
y = 0.5 * x + 1 + rng.standard_normal(60)
fig, ax = plotpress.subplots()
ax.scatter(x, y, s=10, color="C0")
# an infinite line through a point with a slope -- spans the axes, no autoscale
ax.axline((0, 1), slope=0.5, color="C3", linewidth=1.5)
# two points sharing an x -- an undefined (vertical) slope, still a valid
# infinite line through both
ax.axline((6, 0), (6, 8), color="C4", linewidth=1.5, linestyle="--")
ax.set_title("axline (fit reference + a vertical one)")
Total running time of the script: (0 minutes 0.063 seconds)