8000 FIX: there is no add_text method, fallback to add_artist by tacaswell · Pull Request #22116 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

FIX: there is no add_text method, fallback to add_artist #22116

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
merged 1 commit into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ def tables(self):

@property
def texts(self):
return self.ArtistList(self, 'texts', 'add_text',
return self.ArtistList(self, 'texts', 'add_artist',
valid_types=mtext.Text)

def clear(self):
Expand Down
18 changes: 18 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7285,6 +7285,24 @@ def test_artist_sublists():
assert not ax.lines
assert not ax.tables

with pytest.warns(MatplotlibDeprecationWarning,
match='modification of the Axes.texts property'):
ax.texts.append(text)
with pytest.warns(MatplotlibDeprecationWarning,
match='modification of the Axes.collections property'):
ax.collections.append(col)
with pytest.warns(MatplotlibDeprecationWarning,
match='modification of the Axes.images property'):
ax.images.append(im)
with pytest.warns(MatplotlibDeprecationWarning,
match='modification of the Axes.patches property'):
ax.patches.append(patch)
# verify things are back
assert list(ax.collections) == [col]
assert list(ax.images) == [im]
assert list(ax.patches) == [patch]
assert list(ax.texts) == [text]

# Adding items should warn.
with pytest.warns(MatplotlibDeprecationWarning,
match='modification of the Axes.lines property'):
Expand Down
0