Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0f4ec9a

Browse filesBrowse files
committed
FIX: do not replace the Axes._children list object
Each Artist keeps a reference to `Axes._children.remove` as `art._remove_method`. If we replace the `_children` instance on the Axes with a different list instance the Artists will not be updated and their remove method will refer to the wrong list. This will cause subsequent failures on the next draw because on remove we reset the `art.axes` and `art.figure` to None. xref https://discourse.matplotlib.org/t/host-subplot-and-artist-remove/23374
1 parent a5f5af3 commit 0f4ec9a
Copy full SHA for 0f4ec9a

File tree

Expand file treeCollapse file tree

2 files changed

+12
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-1
lines changed

‎lib/mpl_toolkits/axes_grid1/parasite_axes.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/parasite_axes.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def draw(self, renderer):
136136
self._children.extend(ax.get_children())
137137

138138
super().draw(renderer)
139-
self._children = self._children[:orig_children_len]
139+
del self._children[orig_children_len:]
140140

141141
def clear(self):
142142
super().clear()

‎lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,3 +684,14 @@ def test_imagegrid():
684684
im = ax.imshow([[1, 2]], norm=mpl.colors.LogNorm())
685685
cb = ax.cax.colorbar(im)
686686
assert isinstance(cb.locator, mticker.LogLocator)
687+
688+
689+
def test_removal():
690+
import matplotlib.pyplot as plt
691+
import mpl_toolkits.axisartist as AA
692+
fig = plt.figure()
693+
ax = host_subplot(111, axes_class=AA.Axes, figure=fig)
694+
col = ax.fill_between(range(5), 0, range(5))
695+
fig.canvas.draw()
696+
col.remove()
697+
fig.canvas.draw()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.