You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[MNT]: MultiCursor should not take canvas as first parameter #21496
During the sprint, we were looking at widgets, and I noticed that the MultiCursor constructor takes a FigureCanvasBase as first parameter. This probably exists to say where to connect signals, but this does not match how any of the other widgets work, which infer this from the supplied Axes. Theoretically, I don't see any reason why the Axes need to be on a single Figure for MultiCursor to work, but that's implied by it only using a single canvas.
Proposed fix
The canvas should be found from the Axes, and the constructor should assert that all supplied Axes are on the same Figure (if that is indeed required.)
However, I don't know how to deprecate this. If we use _api.delete_parameter, then the remaining parameters become keyword-only, but we don't want to do that to the Axes parameter, which should have been the first positional parameter.
I guess you need to do it more or less by hand, taking *args, **kwargs as parameters and then emit a warning if "canvas" in kwargs or isinstance(args[0], FigureCanvasBase)? Then actually bind the args accordingly. (Something along these lines, untested.)
If we are going to mess up with the signature, perhaps we can also consider changing, at the same time, the somewhat unsightly horizOn/vertOn kwargs to both MultiCursor and Cursor? Currently some widgets use "orientation" and others use "direction", but I think standardizing on "orientation" is better ("direction" is also used for "in"/"out" for ticks, whereas colorbar uses "orientation" for horizontal/vertical).
In the specific case of (Multi)Cursor, I'd suggest going for orientation="vertical"|"horizontal"|"both"?
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Activity
anntzer commentedon Oct 29, 2021
I guess you need to do it more or less by hand, taking
*args, **kwargsas parameters and then emit a warningif "canvas" in kwargs or isinstance(args[0], FigureCanvasBase)? Then actually bind the args accordingly. (Something along these lines, untested.)anntzer commentedon Nov 1, 2021
If we are going to mess up with the signature, perhaps we can also consider changing, at the same time, the somewhat unsightly horizOn/vertOn kwargs to both MultiCursor and Cursor? Currently some widgets use "orientation" and others use "direction", but I think standardizing on "orientation" is better ("direction" is also used for "in"/"out" for ticks, whereas colorbar uses "orientation" for horizontal/vertical).
In the specific case of (Multi)Cursor, I'd suggest going for
orientation="vertical"|"horizontal"|"both"?github-actions commentedon Nov 7, 2025
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
timhoffm commentedon Nov 7, 2025
This now much easier due to the API narrowing in #23348
Deprecate unused canvas parameter to MultiCursor
Deprecate unused canvas parameter to MultiCursor