Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH: update ticks when requesting labels #23170

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

Merged
story645 merged 3 commits into matplotlib:main from jklymak:enh-update-ticks
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
DOC: add change note
  • Loading branch information
jklymak committed Jun 1, 2022
commit bbff015bfca02cde06a0ff352f25cae452cb27ff
6 changes: 6 additions & 0 deletions doc/api/next_api_changes/behavior/23170-JMK.rst
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
``get_ticklabels`` now always populates labels
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Previously `.Axis.get_ticklabels` (and `.Axes.get_xticklabels`,
`.Axes.get_yticklabels`) would only return empty strings unless a draw had
already been performed. Now the ticks and their labels are updated when the
labels are requested.
7 changes: 0 additions & 7 deletions lib/matplotlib/axis.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1343,13 +1343,6 @@ def get_ticklabels(self, minor=False, which=None):
Returns
-------
list of `~matplotlib.text.Text`

Notes
-----
The tick label strings are not populated until a ``draw`` method has
been called.

See also: `~.pyplot.draw` and `~.FigureCanvasBase.draw`.
"""
if which is not None:
if which == 'minor':
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/tests/test_axes.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7773,3 +7773,4 @@ def test_get_xticklabel():
ax.plot(np.arange(10))
for ind in range(10):
assert ax.get_xticklabels()[ind].get_text() == f'{ind}'
assert ax.get_yticklabels()[ind].get_text() == f'{ind}'

AltStyle によって変換されたページ (->オリジナル) /