@@ -2017,12 +2017,19 @@ class MultiCursor(Widget):
20172017 Provide a vertical (default) and/or horizontal line cursor shared between
20182018 multiple Axes.
20192019
2020+ Call signatures::
2021+
2022+ MultiCursor(axes, *, ...)
2023+ MultiCursor(canvas, axes, *, ...) # deprecated
2024+
20202025 For the cursor to remain responsive you must keep a reference to it.
20212026
20222027 Parameters
20232028 ----------
20242029 canvas : object
2025- This parameter is entirely unused and only kept for back-compatibility.
2030+ This parameter is entirely unused.
2031+
2032+ .. deprecated:: 3.11
20262033
20272034 axes : list of `~matplotlib.axes.Axes`
20282035 The `~.axes.Axes` to attach the cursor to.
@@ -2049,11 +2056,25 @@ class MultiCursor(Widget):
20492056 See :doc:`/gallery/widgets/multicursor`.
20502057 """
20512058
2052- def __init__ (self , canvas , axes , * , useblit = True , horizOn = False , vertOn = True ,
2059+ def __init__ (self , * args , useblit = True , horizOn = False , vertOn = True ,
20532060 ** lineprops ):
2054- # canvas is stored only to provide the deprecated .canvas attribute;
2055- # once it goes away the unused argument won't need to be stored at all.
2056- self ._canvas = canvas
2061+ # Deprecation of canvas as the first attribute. When the deprecation expires:
2062+ # - change the signature to __init__(self, axes, *, ...)
2063+ # - delete the "Call signatures" block in the docstring
2064+ # - delete this block
2065+ kwargs = {k : lineprops .pop (k )
2066+ for k in list (lineprops ) if k in ("canvas" , "axes" )}
2067+ params = _api .select_matching_signature (
2068+ [lambda axes : locals (), lambda canvas , axes : locals ()], * args , ** kwargs )
2069+ if "canvas" in params :
2070+ _api .warn_deprecated (
2071+ "3.11" ,
2072+ message = "The canvas parameter in MultiCursor is unused and deprecated "
2073+ "since %(since)s. Please remove it and call MultiCursor(axes) "
2074+ "instead of MultiCursor(canvas, axes). The latter will start raising "
2075+ "an error in %(removal)s"
2076+ )
2077+ axes = params ["axes" ]
20572078
20582079 self .axes = axes
20592080 self .horizOn = horizOn
0 commit comments