From: Alexandre Detiste <tchet@debian.org>
Date: Fri, 19 Jul 2024 23:53:28 +0200
Subject: matplotlib3.8

---
 astroML/plotting/tools.py | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/astroML/plotting/tools.py b/astroML/plotting/tools.py
index 0218fdf..a999240 100644
--- a/astroML/plotting/tools.py
+++ b/astroML/plotting/tools.py
@@ -78,11 +78,9 @@ def devectorize_axes(ax=None, dpi=None, transparent=True):
     im = image.imread(output)
 
     # clear everything on axis (but not text)
-    ax.lines.clear()
-    ax.patches.clear()
-    ax.tables.clear()
-    ax.artists.clear()
-    ax.images.clear()
+    # https://discourse.matplotlib.org/t/recommended-way-of-deleting-lines/22526
+    for art in list(ax.lines) + list(ax.patches) + list(ax.tables) + list(ax.artists) + list(ax.images):
+       art.remove()
 
     # Show the image
     ax.imshow(im, extent=axlim, aspect='auto', interpolation='nearest')
