@@ -1989,12 +1989,19 @@ class MultiCursor(Widget):
19891989 Provide a vertical (default) and/or horizontal line cursor shared between
19901990 multiple Axes.
19911991
1992+ Call signatures::
1993+
1994+ MultiCursor(axes, *, ...)
1995+ MultiCursor(canvas, axes, *, ...) # deprecated
1996+
19921997 For the cursor to remain responsive you must keep a reference to it.
19931998
19941999 Parameters
19952000 ----------
19962001 canvas : object
1997- This parameter is entirely unused and only kept for back-compatibility.
2002+ This parameter is entirely unused.
2003+
2004+ .. deprecated:: 3.11
19982005
19992006 axes : list of `~matplotlib.axes.Axes`
20002007 The `~.axes.Axes` to attach the cursor to.
@@ -2021,11 +2028,25 @@ class MultiCursor(Widget):
20212028 See :doc:`/gallery/widgets/multicursor`.
20222029 """
20232030
2024- def __init__ (self , canvas , axes , * , useblit = True , horizOn = False , vertOn = True ,
2031+ def __init__ (self , * args , useblit = True , horizOn = False , vertOn = True ,
20252032 ** lineprops ):
2026- # canvas is stored only to provide the deprecated .canvas attribute;
2027- # once it goes away the unused argument won't need to be stored at all.
2028- self ._canvas = canvas
2033+ # Deprecation of canvas as the first attribute. When the deprecation exprires:
2034+ # - change the signature to __init__(self, axes, *, ...)
2035+ # - delete the "Call signatures" block in the docstring
2036+ # - delete this block
2037+ kwargs = {k : lineprops .pop (k )
2038+ for k in list (lineprops ) if k in ("canvas" , "axes" )}
2039+ params = _api .select_matching_signature (
2040+ [lambda axes : locals (), lambda canvas , axes : locals ()], * args , ** kwargs )
2041+ if "canvas" in params :
2042+ _api .warn_deprecated (
2043+ "3.11" ,
2044+ message = "The canvas parameter in MultiCursor is unused and deprecated "
2045+ "since %(since)s. Please remove it and call MultiCursor(axes) "
2046+ "instead of MultiCursor(canvas, axes). The latter will start raising "
2047+ "an error in %(removal)s"
2048+ )
2049+ axes = params ["axes" ]
20292050
20302051 self .axes = axes
20312052 self .horizOn = horizOn
0 commit comments