Skip to content
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
10 changes: 10 additions & 0 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,16 @@ def __getitem__(self, key):
for artist in self._axes._children
if self._type_check(artist)][key]

def __add__(self, other):
if isinstance(other, (list, _AxesBase.ArtistList)):
return [*self, *other]
return NotImplemented

def __radd__(self, other):
if isinstance(other, list):
return other + list(self)
return NotImplemented

def insert(self, index, item):
_api.warn_deprecated(
'3.5',
Expand Down
4 changes: 4 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7104,3 +7104,7 @@ def test_artist_sublists():
match='modification of the Axes.lines property'):
ax.lines[1:1] = lines[1:-2]
assert list(ax.lines) == lines

# Adding to other lists should produce a regular list.
assert ax.lines + [1, 2, 3] == [*lines, 1, 2, 3]
assert [1, 2, 3] + ax.lines == [1, 2, 3, *lines]