From 1658f9967402b4cceb316a62870ba74c3db8bee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20N=C3=B6=C3=9Fler?= <60656686+FelixNoessler@users.noreply.github.com> Date: Fri, 29 Oct 2021 05:57:55 +0200 Subject: [PATCH] Backport PR #21492: added parameter documentation for MultiCursor --- lib/matplotlib/widgets.py | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py index 0c8c59176838..35d9ed3bfe4f 100644 --- a/lib/matplotlib/widgets.py +++ b/lib/matplotlib/widgets.py @@ -1677,25 +1677,36 @@ class MultiCursor(Widget): For the cursor to remain responsive you must keep a reference to it. - Example usage:: + Parameters + ---------- + canvas : `matplotlib.backend_bases.FigureCanvasBase` + The FigureCanvas that contains all the axes. + + axes : list of `matplotlib.axes.Axes` + The `~.axes.Axes` to attach the cursor to. - from matplotlib.widgets import MultiCursor - import matplotlib.pyplot as plt - import numpy as np + useblit : bool, default: True + Use blitting for faster drawing if supported by the backend. - fig, (ax1, ax2) = plt.subplots(nrows=2, sharex=True) - t = np.arange(0.0, 2.0, 0.01) - ax1.plot(t, np.sin(2*np.pi*t)) - ax2.plot(t, np.sin(4*np.pi*t)) + horizOn : bool, default: False + Whether to draw the horizontal line. - multi = MultiCursor(fig.canvas, (ax1, ax2), color='r', lw=1, - horizOn=False, vertOn=True) - plt.show() + vertOn: bool, default: True + Whether to draw the vertical line. + Other Parameters + ---------------- + **lineprops + `.Line2D` properties that control the appearance of the lines. + See also `~.Axes.axhline`. + + Examples + -------- + See :doc:`/gallery/widgets/multicursor`. """ + def __init__(self, canvas, axes, useblit=True, horizOn=False, vertOn=True, **lineprops): - self.canvas = canvas self.axes = axes self.horizOn = horizOn