diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 28eaaa827d47..8dfce27bca1f 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -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', diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index a44cecbe162f..2ff65bcad240 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -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]