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

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

merged 2 commits into from
Feb 24, 2019

Conversation

onatt
Copy link

@onatt onatt commented Feb 22, 2019

PR Summary

In an animation using blitting that contains some static graphics elements, the static parts of the figure are not updated after an interactive zoom/pan event. However, they are correctly updated after an resize event (see issue #13478).

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

In an animation using blitting that contains some static graphics elements, the static parts of the figure are not updated after an interactive zoom/pan event. However, they are correctly updated after an resize event.
@jklymak
Copy link
Member

jklymak commented Feb 22, 2019

This seems OK. Is the test just to run what you did in #13478? It would be good if a blitting expert chimed in. Assigning one ;-)

@jklymak jklymak requested a review from WeatherGod February 22, 2019 17:00
@jklymak jklymak added this to the v3.2.0 milestone Feb 22, 2019
Copy link
Contributor

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

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

The change for blotting seems appropriate to me. Minor suggestion on how to handle removing the axis, but no need to hold up for that.

@@ -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

Copy link
Contributor

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

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

Looks good. Not worried about the coverage for the code itself. A little confused why coverage of tests themselves dropped, but there's no reason this change should be involved.

@timhoffm
Copy link
Member

As this is a bugfix, should it go in 3.1?

@dopplershift
Copy link
Contributor

I think that would be appropriate. I think 3.1 branched after it was submitted.

@timhoffm timhoffm modified the milestones: v3.2.0, v3.1.0 Feb 24, 2019
@timhoffm timhoffm merged commit 9221a55 into matplotlib:master Feb 24, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Feb 24, 2019
@lumberbot-app
Copy link

lumberbot-app bot commented Feb 24, 2019

Something went wrong ... Please have a look at my logs.

@onatt onatt deleted the animation-fix-#13478 branch February 24, 2019 09:17
dstansby added a commit that referenced this pull request Feb 24, 2019
…488-on-v3.1.x

Backport PR #13488 on branch v3.1.x (Animation:  interactive zoom/pan with blitting does not work)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants