Use attributes Axes.x/yaxis instead of Axes.get_x/yaxis() #18709
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
We're already largely doing this in code base and examples.
This PR changes some remaining usages and discourages the use of the
getters in their docstrings. For now I'm not going so far as to deprecate the
methods. Keeping them around does little harm.
Note on API consistency: While we generally use getters, I'm not too
worried that people may find this inconsistent. An axis is rather a
sub-part than a property. In particular, it will mostly be used as an
indirection to one of its properties, i.e.
ax.xaxis.get_units()
.Here we still have a final getter call. IMHO it even looks better / more
pythonic than a method chain:
ax.get_xaxis().get_units()
.I'm also not too worried that people may try to overwrite the plain
attributes
Axes.x/yaxis
. While one could turn them into propertiesto protect overwriting, the attributes have already been used widely
in examples and we did not get any complaints.