Skip to content

[ENH]: function naming is inconsistent between, e.g. matplotlib.pyplot and matplotlib.axes.Axes #26207

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

Closed
JohnAtl opened this issue Jun 28, 2023 · 2 comments

Comments

@JohnAtl
Copy link

JohnAtl commented Jun 28, 2023

Problem

I'm always frustrated when: I need to call functions on, say, axes, and my initial attempts fail because a lot of the function names begin with set_, while their pyplot counterparts do not.

ax.set_xlabel('my label') vs. plt.xlabel('my label')
ax.set_title('The Title') vs. plt.title('The Title')

Proposed solution

Perhaps create aliases for the axes functions to match the pyplot functions.

@story645
Copy link
Member

story645 commented Jun 28, 2023

I absolutely get where you're coming from as this is a very frequent source of confusion and frustration, but we've been concerned that exactly matching the OO API to the pyplot API will further blur the boundaries between the two and create more confusion #15938 (comment)

As a general rule, the functions that are methods on the Axes object use the set/get_{} naming convention while the objects that are part of the Matlab like pyplot stateless interface don't, and this is somewhat a legacy of the library code predating python properties.

Is there a different solution that may work here? Possibly a more helpful error message like method does not exist, try set_method/get_method?

ETA: Thinking that may be relatively easy to implement, especially with some upfront work to manually check which methods have correspondences and which don't<-which would maybe be a good page to have in docs? ETA2: Especially since we already document the functions independently in pyplot and axes

@tacaswell
Copy link
Member

@JohnAtl Can we close this issue and keep the discussion in #15938 ?

@jklymak jklymak closed this as not planned Won't fix, can't repro, duplicate, stale Jul 3, 2023
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

4 participants