Skip to content

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

Open

Description

@timhoffm

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

Activity

  1. story645 commented on Sep 4, 2023

    @story645
    Member

    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.

  2. timhoffm commented on Sep 5, 2023

    @timhoffm
    MemberAuthor

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

  3. story645 commented on Sep 5, 2023

    @story645
    Member

    @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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions