Skip to content

Commit e205ce1

Browse files
committed
FIX: remove colorbar from list of colorbars on axes if colorbar is removed
1 parent 039c94a commit e205ce1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/matplotlib/colorbar.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,11 @@ def remove(self):
992992
If the colorbar was created with ``use_gridspec=True`` the previous
993993
gridspec is restored.
994994
"""
995+
if hasattr(self.ax, '_colorbar_info'):
996+
parents = self.ax._colorbar_info['parents']
997+
for a in parents:
998+
a._colorbars.remove(self.ax)
999+
9951000
self.ax.remove()
9961001

9971002
self.mappable.callbacks.disconnect(self.mappable.colorbar_cid)

0 commit comments

Comments
 (0)