Skip to content

Commit f399567

Browse files
committed
FIX: remove colorbar from list of colorbars on axes if colorbar is removed
1 parent a19324c commit f399567

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/matplotlib/colorbar.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,12 @@ 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+
if self.ax in a._colorbars:
999+
a._colorbars.remove(self.ax)
1000+
9951001
self.ax.remove()
9961002

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

0 commit comments

Comments
 (0)