Step plots

A selection on a step plot holds precise information on the x and y position in the sub-attribute.

from matplotlib import pyplot as plt
import mplcursors
import numpy as np

fig, axs = plt.subplots(4, sharex=True, sharey=True)
xs = np.arange(5)
ys = np.random.rand(5)

axs[0].plot(xs, ys, "-o")
axs[1].plot(xs, ys, "-o", drawstyle="steps-pre")
axs[2].plot(xs, ys, "-o", drawstyle="steps-mid")
axs[3].plot(xs, ys, "-o", drawstyle="steps-post")
for ax in axs:

    lambda sel: sel.annotation.set_text(format(, ".2f")))

Gallery generated by Sphinx-Gallery