10000 Animation: interactive zoom/pan with blitting does not work by onatt · Pull Request #13488 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Animation: interactive zoom/pan with blitting does not work #13488

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

Merged
merged 2 commits into from
Feb 24, 2019
Merged
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,14 @@ def _setup_blit(self):
# axes
self._blit_cache = dict()
self._drawn_artists = []
def remove_from_cache(ax):
try:
del self._blit_cache[ax]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could replace the whole block with:

self._blit_cache.pop(ax, None)

Copy link
Author

Choose a reason for hiding this comment

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

@dopplershift,
I really like your proposal. The second argument of dict.pop did not come to my mind. We could make my proposal much more concise:

        self._drawn_artists = []
        for ax in self._fig.axes:
            ax.callbacks.connect('xlim_changed',
                                 lambda ax: self._blit_cache.pop(ax, None))
            ax.callbacks.connect('ylim_changed',
                                 lambda ax: self._blit_cache.pop(ax, None))
        self._resize_id = self._fig.canvas.mpl_connect('resize_event',
                                                       self._handle_resize)

This was my first contribution to matplotlib. Shall I file another pull request for this modification?

Copy link
Member

Choose a reason for hiding this comment

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

@onatt, no just modify this PR, add a new commit on your machine, and then push... https://matplotlib.org/devel/index.html

except KeyError:
pass
for ax in self._fig.axes:
ax.callbacks.connect('xlim_changed', remove_from_cache)
ax.callbacks.connect('ylim_changed', remove_from_cache)
self._resize_id = self._fig.canvas.mpl_connect('resize_event',
self._handle_resize)
self._post_draw(None, self._blit)
Expand Down
0