Skip to content

[MNT]: Inconsistent API Figure.suptitle() #26691

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

Open
timhoffm opened this issue Sep 4, 2023 · 3 comments
Open

[MNT]: Inconsistent API Figure.suptitle() #26691

timhoffm opened this issue Sep 4, 2023 · 3 comments

Comments

@timhoffm
Copy link
Member

timhoffm commented Sep 4, 2023

Summary

@story645 noted in #26629 (comment)

Why is it Figure.suptitle() and not Figure.set_suptitle(). Same with Figure.supxlabel() / Figure.supylabel().

And related: Should we do something about this?

Proposed fix

No response

@story645
Copy link
Member

story645 commented Sep 4, 2023

Should we do something about this?

I know it's ugly, but adding the get_{property} methods as aliases would preserve consistency.

I agree w/ @jklymak that property versions like ax.xlabel would be nice #26629 (comment) and that's something folks have been asking for for ages, that instead of {get,set}_property, they could behave like python properties - but that's also a project and a half.

@timhoffm
Copy link
Member Author

timhoffm commented Sep 5, 2023

@jklymak proposed set-less functions ax.xlabel(name), not properties ax.xlabel = name. Properties would be much more difficult because we often have optional parameters. I can see the argument for xlabel(). Semantically, this is more a declarative style compared to the imperative set_*. We'd also move logic closer to pyplot so that for setters they are equivalent plt.xlabel(name) / ax.xlabel(name). This could be nice, because we already have this parallelism for the functions adding data (like plot()). OTOH, we'd have to decide on getters. I don't think we want the MATLABism of pyplot "calling a function without arguements returns the current value". IMHO we still have to stick with getters. But that's ok; they are much less used.

That said, this would be a major API overhaul, and we'd have yet another way. While it's reasonable on its own. We should carefully decide wether we want that additional API surface, whether we want to afford this change knowing that there is more to come e.g. mpl-gui, and if we are touching on the API whether other patterns like e.g. method chaining (plot(x, y).xlabel('the x').ylabel('the y') are an option.

@story645
Copy link
Member

story645 commented Sep 5, 2023

@jklymak proposed set-less functions ax.xlabel(name), not properties ax.xlabel = name.

Yeah, I should have said property-like b/c I was thinking of the pyplot pattern where the function is both the getter and setter. Which yeah, we'd want for consistency between the two APIs.

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