Skip to content
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

Cleanup animation examples #10125

Merged
merged 2 commits into from Jan 17, 2018

Conversation

Projects
None yet
5 participants
@anntzer
Copy link
Contributor

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 anntzer:anim-examples branch 6 times, most recently from 8fa927f to 6fe22f0 Dec 29, 2017

@tacaswell tacaswell added this to the v2.2 milestone Dec 31, 2017

@tacaswell

This comment has been minimized.

Copy link
Member

commented Dec 31, 2017

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

@tacaswell

This comment has been minimized.

Copy link
Member

commented Dec 31, 2017

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)

This comment has been minimized.

Copy link
@tacaswell

tacaswell Jan 1, 2018

Member

This sets the initial data to be a line?

This comment has been minimized.

Copy link
@anntzer

anntzer Jan 1, 2018

Author Contributor

good catch, fixed

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

This comment has been minimized.

Copy link
@tacaswell

tacaswell Jan 1, 2018

Member

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

This comment has been minimized.

Copy link
@anntzer

anntzer Jan 1, 2018

Author Contributor

fixed


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

This comment has been minimized.

Copy link
@tacaswell

tacaswell Jan 1, 2018

Member

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

This comment has been minimized.

Copy link
@anntzer

anntzer Jan 1, 2018

Author Contributor

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

This comment has been minimized.

Copy link
Contributor Author

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 anntzer:anim-examples branch 4 times, most recently from edb8bd2 to a6d2aca Jan 1, 2018

@dstansby

This comment has been minimized.

Copy link
Contributor

commented Jan 9, 2018

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

@dopplershift

This comment has been minimized.

Copy link
Contributor

commented Jan 17, 2018

Of course, now there's a conflict.

anntzer added some commits Dec 29, 2017

Cleanup animation examples
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 anntzer force-pushed the anntzer:anim-examples branch from a6d2aca to 5f0a823 Jan 17, 2018

@anntzer

This comment has been minimized.

Copy link
Contributor Author

commented Jan 17, 2018

rebased

@dstansby

This comment has been minimized.

Copy link
Contributor

commented Jan 17, 2018

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

4 of 5 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
ci/circleci: docs-python27 Your tests passed on CircleCI!
Details
ci/circleci: docs-python35 Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
lgtm analysis: Python No alert changes
Details

@anntzer anntzer deleted the anntzer:anim-examples branch Jan 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.