Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Sorting drawn artists by their zorder when blitting using FuncAnimation #11370

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 3 commits into from
Jul 5, 2018

Conversation

jdollichon
Copy link

@jdollichon jdollichon commented Jun 2, 2018

PR Summary

As pointed out in issue #11369 using blitting with FuncAnimation can lead to unexpected bevahior with overlapping artists. Essentially their zorder is not being respected, as instead the order in which they are provided by the user-function defines the order in which they are drawn. Sorting artists by their zorder when reciveing them fixes this issue.

PR Checklist

  • (not applicable) Has Pytest style unit tests
  • Code is PEP 8 compliant
  • (not applicable) New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • (not applicable) 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

@tacaswell tacaswell added this to the v3.0 milestone Jun 2, 2018
@tacaswell
Copy link
Member

This seems reasonable, but the current behavior (using the order the user explicitly passed us) is also reasonable. One concern about sorting here is that while z-order will be respected in this list, they will all be drawn above any existing artists.

Can you also add at API change note (as anyone who is relying on the behavior of drawing in the order they passed the artists in will be broken) and update the docs for FuncAnimation to make this behavior clear?

Alternately, would updating the docs to be clear that the artists are drawn in the order the user passed them in (as the user has full control of that).

@ImportanceOfBeingErnest
Copy link
Member

Just my personal opinion here: I would say that since blitting is used for fast operations one should not slow it down by introducing a sorting step. In the end, if the user needs the artists to be sorted they can do it in the animating function.

@Tillsten
Copy link
Contributor

Tillsten commented Jun 3, 2018

I seriously doubt that the sorting would impact the performance measurably. I also think that respecting the relative zorder is the right thing to do.

@tacaswell tacaswell requested a review from dopplershift June 4, 2018 14:03
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.

IMO this is an improvement if only because it makes the difference between True and False for blit slightly less.

@jklymak jklymak merged commit 300e4c9 into matplotlib:master Jul 5, 2018
@jklymak
Copy link
Member

jklymak commented Jul 5, 2018

Thanks @jdollichon !

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.

7 participants