Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d6ed6ce

Browse files
authored
Merge pull request #22116 from tacaswell/fix_ArtistList_append
FIX: there is no add_text method, fallback to add_artist
2 parents d5a46ba + 815b8ad commit d6ed6ce

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ def tables(self):
14671467

14681468
@property
14691469
def texts(self):
1470-
return self.ArtistList(self, 'texts', 'add_text',
1470+
return self.ArtistList(self, 'texts', 'add_artist',
14711471
valid_types=mtext.Text)
14721472

14731473
def clear(self):

lib/matplotlib/tests/test_axes.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7285,6 +7285,24 @@ def test_artist_sublists():
72857285
assert not ax.lines
72867286
assert not ax.tables
72877287

7288+
with pytest.warns(MatplotlibDeprecationWarning,
7289+
match='modification of the Axes.texts property'):
7290+
ax.texts.append(text)
7291+
with pytest.warns(MatplotlibDeprecationWarning,
7292+
match='modification of the Axes.collections property'):
7293+
ax.collections.append(col)
7294+
with pytest.warns(MatplotlibDeprecationWarning,
7295+
match='modification of the Axes.images property'):
7296+
ax.images.append(im)
7297+
with pytest.warns(MatplotlibDeprecationWarning,
7298+
match='modification of the Axes.patches property'):
7299+
ax.patches.append(patch)
7300+
# verify things are back
7301+
assert list(ax.collections) == [col]
7302+
assert list(ax.images) == [im]
7303+
assert list(ax.patches) == [patch]
7304+
assert list(ax.texts) == [text]
7305+
72887306
# Adding items should warn.
72897307
with pytest.warns(MatplotlibDeprecationWarning,
72907308
match='modification of the Axes.lines property'):

0 commit comments

Comments
 (0)