Skip to content
3 changes: 1 addition & 2 deletions lib/matplotlib/tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1823,8 +1823,7 @@ def test_cursor_overlapping_axes_blitting_warning():
"""Test that a warning is raised and useblit is disabled for overlapping axes."""
fig = plt.figure()
ax1 = fig.add_axes([0.1, 0.1, 0.8, 0.8])
ax2 = fig.add_axes([0.2, 0.2, 0.6, 0.6]) # Explicitly overlaps ax1

Comment on lines -1826 to -1827

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't change!

ax2 = fig.add_axes([0.2, 0.2, 0.6, 0.6])
match_text = (
"Cursor blitting is currently not supported on "
"overlapping axes"
Expand Down
7 changes: 6 additions & 1 deletion lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2119,7 +2119,12 @@ def onmove(self, event):
self.linev.set_visible(False)
self.lineh.set_visible(False)
if self.needclear:
self.canvas.draw()
background = self._load_blit_background()
if self.useblit and background is not None:
self.canvas.restore_region(background)
self.canvas.blit(self.ax.bbox)
else:
self.canvas.draw()
Comment thread
timhoffm marked this conversation as resolved.
Resolved
self.needclear = False
return
self.needclear = True
Expand Down
Loading