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

Feature Proposal: SVGFuncAnimation#20142

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

Draft
jungerm2 wants to merge7 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromjungerm2:svganim

Conversation

jungerm2
Copy link

@jungerm2jungerm2 commentedMay 3, 2021
edited
Loading

PR Summary

This PR stems from#19694. It implements a new animation classSVGFuncAnimation that exclusively creates SVG animations. Because of this restriction, it can reuse components that are common between frames and thus only minimally updates the SVG dom for each frame. In my tests, I found that this results in a speedup of up to 30x and about half the memory footprint as compared to the standardFuncAnimation.

It's meant to be (almost) a drop-in forFuncAnimation and can be used as such:

np.random.seed(0)size=10defupdate_line(num,data,line):line.set_data(range(num),data[:num])returnline,fig=plt.figure()data=np.random.rand(size)l,=plt.plot([], [],'r-')plt.xlim(0,size-1)plt.ylim(0,1)anim=SVGFuncAnimation(fig,update_line,range(1,size+1),fargs=(data,l))

I have a few other exampleshere and a basic benchmarkhere.

This is a new feature (and my first PR here) so I suspect there'll be some discussion about what the proper API for this is and quite a few things to correct/fix. This is part of the reason I have yet to write more extensive docs. Any and all feedback is welcomed!

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • 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).

@jklymak
Copy link
Member

Perhaps give us a mock example in the PR description?

jungerm2 reacted with thumbs up emoji

Copy link

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping@matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

We strive to be a welcoming and open project. Please follow ourCode of Conduct.

@jungerm2
Copy link
Author

jungerm2 commentedMay 3, 2021
edited
Loading

It looks like the signature of functool's lru_cache changed after py37. Should be a quick fix, I'll push an update to this shortly.

EDIT: It's fixed now. All tests pass 👍

@QuLogic
Copy link
Member

What makes this specifically need to be anAnimation, and not aWriter?

@jungerm2
Copy link
Author

Originally, instead of hooking into the SVG backend to intercept the frame data, I had it parse every frame separately which meant it couldn't be just aWriter. The current code is more simple so we might be able to make it inherit fromMovieWriter orFileMovieWriter.

One of the subtleties with making it aWriter would be whether or not to extend theHTMLWriter or simply create its own class. After all the output format of theSVGFunAnimation is pretty similar to the output of theHTMLWriter. It uses a similar jshtml output except that the js edits the SVG dom instead of swapping out an img tag. We'd need a separateto_svghtml or maybe just add an option to theto_jshtml call if we make this a writer.

@jklymak
Copy link
Member

@tacaswell, you encouraged this to be PRd, so I'll ping you to shepherd this through if you have the bandwidth?@jungerm2 did a lot of work here, and it seems reasonable to me, but its a lot of new code...

@tacaswell
Copy link
Member

tacaswell commentedMay 15, 2021
edited
Loading

I will not realistically have bandwidth to look at this until next week.

@jungerm2 If you do not hear from me by May 26 please ping me!

jklymak and jungerm2 reacted with thumbs up emoji

@jungerm2
Copy link
Author

Will do, Thanks! Let me know if there's anything I can help with too (time permitting). But as@QuLogic mentioned it might make more sense to make this into aWriter, I'm just not totally sure how that would work...

@jklymakjklymak marked this pull request as draftMay 22, 2021 15:50
@jungerm2
Copy link
Author

@tacaswell were you able to take a look at this PR yet?

@melissawm
Copy link
Member

Hi@jungerm2 - I'm sorry this fell through the cracks, are you interested in continuing this work? If so, please mark the PR as ready for review and let us know if you need help with the rebase, we haveinstructions for that here. Thanks!

@jungerm2
Copy link
Author

Hey, thanks for getting back to me! It's been a while since I've worked on this but still think it would add value to matplotlib, but it seems there are quite a few merge conflicts now. And as I've said this might be better implemented as aWriter class. It would be great to get some feedback on this.

If there's sufficient interest I might pick this back up but don't have the bandwidth to merge this in at the moment.

melissawm and bsierro reacted with thumbs up emoji

@tacaswell
Copy link
Member

I took the liberty of doing the rebase.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

@tacaswelltacaswellAwaiting requested review from tacaswell

At least 1 approving review is required to merge this pull request.

Assignees

@tacaswelltacaswell

Projects
Status: Needs decision
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@jungerm2@jklymak@QuLogic@tacaswell@melissawm

[8]ページ先頭

©2009-2025 Movatter.jp