Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Animation Tutorial#24274

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
QuLogic merged 29 commits intomatplotlib:mainfromchahak13:animation-tutorial
Nov 23, 2022
Merged

Conversation

chahak13
Copy link
Contributor

PR Summary

A one-stop tutorial that covers all the major points of creating an animation using thematplotlib.animation module. (Reference issue:#24228 by@story645)

PR Checklist

Tests and Styling

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (installflake8-docstrings and runflake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).

@story645story645 self-assigned thisOct 25, 2022
@story645
Copy link
Member

What sort of feedback would be helpful at this stage?

@story645story645 linked an issueOct 25, 2022 that may beclosed by this pull request
@chahak13
Copy link
ContributorAuthor

I don't think I've added that much right now to have any suggestions particularly, but just in general, is the type of animation okay for the plots? I was thinking to keep them very simple and distraction-free so as to focus more on the process of animating rather than the data that it animates.

story645 reacted with thumbs up emoji

@story645
Copy link
Member

story645 commentedOct 25, 2022
edited
Loading

Yeah if anything I'd suggest going even simpler and just using sin/cos/unit circle so you can remove the data generation functions

@chahak13
Copy link
ContributorAuthor

@story645 can you take a look at this? I think I have this as a first draft and would appreciate feedback! I had a question too, actually. I'm not sure why the Lines2D animation is not showing up correctly. I tried saving it locally as .html and that seems to be working fine but for some reason, it isn't working correctly in the docs.

@chahak13
Copy link
ContributorAuthor

@story645 thanks for the feedback! I've updated most of the things. Let me know if there are more things to change :)

@chahak13
Copy link
ContributorAuthor

Something's still wrong with the line plot though. Working on it.

The animation for Lines2D was not showing the animation properly but wasshowing just the final frame. Adding an init function resolved thisissue and the animation appears correctly now.
@chahak13
Copy link
ContributorAuthor

Okay, the line plot seems to be working now. For some reason, adding aninit_func resolved the issue where it was showing just the final frame. Maybe it is because if there's no function, it just starts out with the final frame? I don't know, just speculating. I'm not sure if this would be the ideal solution for it either. Let me know if there's a better way to resolve this. Thanks!

Copy link
Member

@story645story645 left a comment
edited
Loading

Choose a reason for hiding this comment

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

I think the bones are awesome! I also think this is in large enough scope that it needs a second review.

I left it out of my outline so my mistake, but I think it'd be useful to briefly go through the various methods onanimation with possibly puttingto_jshtml andto_html_video at the bottom as part of a saving section

edit: also my bias for the line is somethingsimple unless you can explain what the deleting values is about. Alternatively, I was able to remove the init by pulling the axes setting outside the initax.set(ylim=(-1.1, 1.1), xlim=(0, 5))

Comment on lines 99 to 105
fig, ax = plt.subplots()
rng = np.random.default_rng()
t = np.linspace(-4, 4, 400)
a, b = 3, 2
delta = np.pi / 2

scat = ax.scatter(np.sin(a * t[0] + delta), np.sin(b * t[0]), c="b", s=2)
Copy link
Member

Choose a reason for hiding this comment

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

I really like reusing an example and showing a different method of doing the same thing, so I'd suggest then you reuse scatter. Or pick something that's really well suited to artist animation, but I'm honestly not sure what that would be.

chahak13 reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

"Animating Markers" and "Animating Images" are structurally very similar to "Animating Lines". IMHO they don't explain something new (other than you use differentset_* methods to manipulate the artists.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but the different set_* methods is kind of the point, unless there's a different way to structure this so it's clear that the key to animation is finding that artistsset_data equivalent -> maybe a table?

@chahak13
Copy link
ContributorAuthor

Alternatively, I was able to remove the init by pulling the axes setting outside the initax.set(ylim=(-1.1, 1.1), xlim=(0, 5))

I had the same thing before but what this led to was that the animation used to get stuck at the last frame after building the docs. This did not happen if I just saved the animation as.html
image

@chahak13
Copy link
ContributorAuthor

I changed it to the simple example you linked and that works for some reason, so let me put that instead!

@story645
Copy link
Member

Forgot that the decay example doesn't have explicit frames but the docs save out to 100 and that might be why things are inconsistent.

@chahak13
Copy link
ContributorAuthor

Ah okay. Yeah, that might be the case. Thanks for that!

@chahak13
Copy link
ContributorAuthor

@story645 I changed to an example that shows a 2d gaussian pdf with increasing covariance (kind of a raindrop effect). I feel that this shows the changes in the image in a better way and also allows the example to not be extremely convoluted. This also allows reusing the same in ArtistAnimation. Let me know, thanks!

story645 reacted with thumbs up emoji

@story645
Copy link
Member

Wondering if for the artist animation you should add an additional artist to each list? Maybe a marker that moves across the page or something?

Copy link
Member

@story645story645 left a comment

Choose a reason for hiding this comment

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

Thanks for pinging me, I hope these are minor changes.

I think this is a great starting base that has all the important bits.

Copy link
Member

@story645story645 left a comment

Choose a reason for hiding this comment

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

It exists! I think this has all the important bits written out in a way that's more user friendly than the API docs and isn't overwhelming 😁

I'm not sure if this is significant enough to need a 2nd review.

chahak13 reacted with heart emoji
@chahak13chahak13 changed the title[WIP] Animation TutorialAnimation TutorialNov 17, 2022
@story645
Copy link
Member

Hey folks, since this is documentation my plan is that if there are no reviews over the weekend then I'll merge Monday if there are no objections.

@chahak13
Copy link
ContributorAuthor

Thanks@QuLogic! That should fix all of the comments.

@QuLogicQuLogic merged commitde58d98 intomatplotlib:mainNov 23, 2022
@QuLogic
Copy link
Member

I squash merged as it's unlikely we need all 29 commits preserved.

story645 and chahak13 reacted with hooray emoji

melissawm pushed a commit to melissawm/matplotlib that referenced this pull requestDec 19, 2022
* First version of animation tutorial* Simplify examples by removing data gen functions* Add tutorial text* Format to agree with flake8* Update tutorial and scatter example* Fix example for line animationThe animation for Lines2D was not showing the animation properly but wasshowing just the final frame. Adding an init function resolved thisissue and the animation appears correctly now.* Change to simpler line animation example* Change headings and update set_offsets description* Change writer type to pipe-based from standard* Update saving animation section* Add new example for images and ArtistAnimation* Remove unused variables* Correct type of animation class* Remove unused variable* Correct wrong correction* Update ArtistAnimation example to use bar chart* Barchart race example for ArtistAnimation* Change FuncAnimation to have one general guideline* Add a table for set methods for example artists* Add plotting method, return artist type table* Reword to avoid confusion* Reposition note about pipe based writers* Change color and don't sort bar chart* Remove animation code in save animation section* Change inline codeblocks to clear CI* Make small corrections as per code review* Remove :class: from links* Set the animation range so that it loops* Update to better animation range for scatter
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell left review comments

@timhoffmtimhoffmtimhoffm left review comments

@oscargusoscargusoscargus left review comments

@QuLogicQuLogicQuLogic approved these changes

@story645story645story645 approved these changes

Assignees

@story645story645

Projects
None yet
Milestone
v3.7.0
Development

Successfully merging this pull request may close these issues.

[Doc]: Create Animation Tutorial
6 participants
@chahak13@story645@QuLogic@tacaswell@timhoffm@oscargus

[8]ページ先頭

©2009-2025 Movatter.jp