The Wayback Machine - https://web.archive.org/web/20230308191921/https://github.com/matplotlib/matplotlib/issues/21496
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNT]: MultiCursor should not take canvas as first parameter #21496

Open
QuLogic opened this issue Oct 29, 2021 · 2 comments
Open

[MNT]: MultiCursor should not take canvas as first parameter #21496

QuLogic opened this issue Oct 29, 2021 · 2 comments

Comments

@QuLogic
Copy link
Member

QuLogic commented Oct 29, 2021

Summary

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.

@anntzer
Copy link
Contributor

anntzer commented Oct 29, 2021

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.)

@anntzer
Copy link
Contributor

anntzer commented 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"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants