Visitar URL original
[ENH]: AxLine xy1/xy2 setters should take xy as single parameters, (possibly) not separate ones · Issue #28800 · matplotlib/matplotlib · GitHub
The Wayback Machine - https://web.archive.org/web/20240926120237/https://github.com/matplotlib/matplotlib/issues/28800
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

[ENH]: AxLine xy1/xy2 setters should take xy as single parameters, (possibly) not separate ones #28800

Open
anntzer opened this issue Sep 11, 2024 · 1 comment

Comments

@anntzer
Copy link
Contributor

anntzer commented Sep 11, 2024 •

Problem

Currently, AxLine.set_xy1 and set_xy2 take x and y as separate parameters. They should also take them as a single xy parameter, which is consistent with most other setters and would in particular allow the idiom line.set(xy1=..., xy2=...) (or line.set(xy1=..., slope=...).

Proposed solution

Given that the setters were only introduced only in Matplotlib 3.8, we could even consider just deprecating the split (x, y) form out and ultimately only supporting a single xy tuple (tagging this issue for 3.10 as we probably don't want to wait too long in that case); or we can support both forms with the standard dance present e.g. in Axes.set_xlim.

@timhoffm
Copy link
Member

timhoffm commented Sep 11, 2024 •

I see the need. I believe we're quite inconsistent with this throughout the library.

There's always a tradeoff between simplicity, consistency and usability. I'm not decided whether the slightly simpler code and documentation outweighs the need for users to write set_xy1((x, y)) - it's easy to forget the additional braces, in particular also because we have that in other places.

Anyway, we need to start with supporting both for compatibility reasons. When we have that implementation, it's possibly easier to decide whether it's simple enough or whether we want to get rid of it.

Reconsidering: The only two other set_xy() methods are Polygon.set_xy and Rectangle.set_xy. Both take only a single parameter. Therefore, let's deprecate the two-arg version.

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