Skip to content

Matplotlib blitting in Jupyter Notebooks (issue #4288) #9240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/matplotlib/backends/backend_webagg_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _handle_key(key):


class FigureCanvasWebAggCore(backend_agg.FigureCanvasAgg):
supports_blit = False
supports_blit = True

def __init__(self, *args, **kwargs):
backend_agg.FigureCanvasAgg.__init__(self, *args, **kwargs)
Expand Down Expand Up @@ -162,9 +162,17 @@ def draw(self):
# Swap the frames
self.manager.refresh_all()

def blit(self, bbox=None):
self._png_is_old = True
self.manager.refresh_all()

def draw_idle(self):
self.send_event("draw")

def copy_from_bbox(self, bbox):
renderer = self._last_renderer
return renderer.copy_from_bbox(bbox)

def set_image_mode(self, mode):
"""
Set the image mode for any subsequent images which will be sent
Expand Down Expand Up @@ -215,6 +223,11 @@ def get_diff_image(self):
# Swap the renderer frames
self._renderer, self._last_renderer = (
self._last_renderer, renderer)

self.figure._cachedRenderer = self._renderer
for ax in self.figure.axes:
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't cache the renderer on the axes anymore, so these two lines should go away

ax._cachedRenderer = self._renderer

self._force_full = False
self._png_is_old = False
return buff
Expand Down
Loading