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

Skip to content

Cleanup animation examples #10125

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
Jan 17, 2018
Merged

Cleanup animation examples #10125

merged 2 commits into from
Jan 17, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Dec 29, 2017

I thought that the animation examples section was a bit of an unstructured mess so I tried to reorganize it somewhat. The suggested new list of examples (open to discussion, of course) is

simple examples

animation_demo: plt.pause example
simple_anim: FuncAnimation example
dynamic_image: FuncAnimation example
dynamic_image2: ArtistAnimation example

intermediate examples

strip_chart: FuncAnimation example

advanced examples

histogram: animating a composite artist (namely, a histogram)

nice examples

bayes: FuncAnimation example
double_pendulum: FuncAnimation example, skipped as needing scipy
random_walk (renamed from simple_3danim): FuncAnimation example
rain: FuncAnimation example
unchained: FuncAnimation example

movie writing

frame_grabbing_sgskip (renamed from moviewriter_sgskip.py)

removed

animate_decay: overlaps with simple_anim
basic_example: equivalent to {simple_anim + dynamic_image2}
basic_example_writer_sgskip: split as comments to
simple_anim/dynamic_image/dynamic_image2
random_data: overlaps with simple_anim, though using a generator
subplots: relies on subclassing private attributes of TimedAnimation, would
better be replaced by a FuncAnimation example, overly complex


It would be nice if s-g allowed for an easier way to set the example order, but that's for another time...

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 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

@anntzer anntzer force-pushed the anim-examples branch 6 times, most recently from 8fa927f to 6fe22f0 Compare December 29, 2017 06:48
@tacaswell tacaswell added this to the v2.2 milestone Dec 31, 2017
@tacaswell
Copy link
Member

It is probably worth preserving an example of FuncAnimation that uses a generator.

@tacaswell
Copy link
Member

I think it is fair to require scipy to build the docs (but not in the library).

def animate(i):
line.set_ydata(np.sin(x + i/10.0)) # update the data
def init(): # only required for blitting to give a clean slate.
line.set_ydata(x)
Copy link
Member

Choose a reason for hiding this comment

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

This sets the initial data to be a line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, fixed

# or
#
# from matplotlib.animation import FFMpegWriter
# writer = Writer(fps=15, metadata=dict(artist='Me'), bitrate=1800)
Copy link
Member

Choose a reason for hiding this comment

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

This should be FFMpegWriter or the above line should be ... as Writer. Same for other files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


if t >= xmax:
ax.set_xlim(xmin, 2*xmax)
ax.figure.canvas.draw()
Copy link
Member

Choose a reason for hiding this comment

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

This one shows how to force a change to the limits in the update function, is that shown else where still?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to retsore the example (also showcasing the use of a generator as you mentioned above) and remove dynamic_image instead (renaming dynamic_image2 (ArtistAnimation) to it).

@anntzer
Copy link
Contributor Author

anntzer commented Jan 1, 2018

Re: scipy: I rewrote bayes to not use scipy (it's not the end of the world to write the beta pdf). double pendulum needs an ode solver, but it's not as if s-g can show animations anyways so I think it's fine to leave it as sgskipped.

@anntzer anntzer force-pushed the anim-examples branch 4 times, most recently from edb8bd2 to a6d2aca Compare January 2, 2018 00:51
@dstansby
Copy link
Member

dstansby commented Jan 9, 2018

(going to let someone else review and merge since it involves removing stuff from the docs, but I'm 👍 )

@dopplershift
Copy link
Contributor

Of course, now there's a conflict.

I thought that the animation examples section was a bit of an
unstructured mess so I tried to reorganize it somewhat.  The new list of
examples is

simple examples
===============
animation_demo: plt.pause example
simple_anim: FuncAnimation example
dynamic_image: FuncAnimation example
dynamic_image2: ArtistAnimation example

intermediate examples
=====================
strip_chart: FuncAnimation example

advanced examples
=================
histogram: animating a composite artist (namely, a histogram)

nice examples
=============
bayes: FuncAnimation example
double_pendulum: FuncAnimation example, skipped as needing scipy
random_walk (renamed from simple_3danim): FuncAnimation example
rain: FuncAnimation example
unchained: FuncAnimation example

movie writing
=============
frame_grabbing_sgskip (renamed from moviewriter_sgskip.py)

removed
=======
animate_decay: overlaps with simple_anim
basic_example: equivalent to {simple_anim + dynamic_image2}
basic_example_writer_sgskip: split as comments to
  simple_anim/dynamic_image/dynamic_image2
random_data: overlaps with simple_anim, though using a generator
subplots: relies on subclassing private attributes of TimedAnimation, would
  better be replaced by a FuncAnimation example, overly complex
@anntzer
Copy link
Contributor Author

anntzer commented Jan 17, 2018

rebased

@dstansby
Copy link
Member

Since life's too short to wait for a travis OSX build to complete on a doc PR, I'm going to merge this.

@dstansby dstansby merged commit f4bcca3 into matplotlib:master Jan 17, 2018
@anntzer anntzer deleted the anim-examples branch January 18, 2018 00:57
@QuLogic QuLogic removed this from the needs sorting milestone Feb 12, 2018
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.

5 participants