Callback mechanism for animation completed?

I am trying to chain together a series of animations. Is there a callback mechanism of some sort that could be used to launch a new animation when another animation completes?

When you say "another animation" do you mean different data on the same
artists in the same figure, different artists in the same figure or a
different figure altogether?

In the first cases I think you could use a generator to sticky tape your
data together. In the second two you will have to roll your own.

Do you need to be able to change the chain while it is running? If so, what
are you using to get your concurrencey?

Tom

···

On Mon, Jan 8, 2018, 12:38 Paul Deitel <paul.deitel at deitel.com> wrote:

I am trying to chain together a series of animations. Is there a callback
mechanism of some sort that could be used to launch a new animation when
another animation completes?

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180109/1b10efa0/attachment.html>

Hi Tom,

Thanks for your response.

Same figure/artists.

Basically, for the function called by FuncAnimation, I?d like one of my custom arguments to change after some number of frames. I did not find a good way to do that, so I was thinking I could have one animation that does the first set of frames with the initial custom argument value, followed by another animation that does the remaining frames with a different custom argument value.

Thanks,
Paul

···

On Jan 9, 2018, at 8:15 AM, Thomas Caswell <tcaswell at gmail.com> wrote:

When you say "another animation" do you mean different data on the same artists in the same figure, different artists in the same figure or a different figure altogether?
In the first cases I think you could use a generator to sticky tape your data together. In the second two you will have to roll your own.

Do you need to be able to change the chain while it is running? If so, what are you using to get your concurrencey?

Tom

On Mon, Jan 8, 2018, 12:38 Paul Deitel <paul.deitel at deitel.com <mailto:paul.deitel at deitel.com>> wrote:
I am trying to chain together a series of animations. Is there a callback mechanism of some sort that could be used to launch a new animation when another animation completes?

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org <mailto:Matplotlib-users at python.org>
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180109/27502e01/attachment-0001.html>

Paul,

Sorry for the very late response!

I would suggest passing in a function as a custom argument which takes the
frame number and returns your parameter.

For example (modified from the docs)

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation

decades = 5

fig, ax = plt.subplots()
xdata, ydata = [], []
ln, = plt.plot([], [], 'ro', animated=True)
ax.set_xlim(1, 10**decades)
ax.set_ylim(1, (10.0**(decades*(decades - 1))))
ax.set_yscale('log')
ax.set_xscale('log')

def init():
    return ln,

def update(frame, exp_func):
    xdata.append(frame)
    ydata.append(frame ** exp_func(frame))
    ln.set_data(xdata, ydata)
    return ln,

ani = FuncAnimation(fig, update, frames=np.logspace(0, decades),
                    init_func=init, blit=True,
                    fargs=(lambda frame: int(np.log10(frame)),))
plt.show()

Tom

···

On Tue, Jan 9, 2018 at 11:50 AM Paul Deitel <paul.deitel at deitel.com> wrote:

Hi Tom,

Thanks for your response.

Same figure/artists.

Basically, for the function called by FuncAnimation, I?d like one of my
custom arguments to change after some number of frames. I did not find a
good way to do that, so I was thinking I could have one animation that does
the first set of frames with the initial custom argument value, followed by
another animation that does the remaining frames with a different custom
argument value.

Thanks,
Paul

On Jan 9, 2018, at 8:15 AM, Thomas Caswell <tcaswell at gmail.com> wrote:

When you say "another animation" do you mean different data on the same
artists in the same figure, different artists in the same figure or a
different figure altogether?

In the first cases I think you could use a generator to sticky tape your
data together. In the second two you will have to roll your own.

Do you need to be able to change the chain while it is running? If so,
what are you using to get your concurrencey?

Tom

On Mon, Jan 8, 2018, 12:38 Paul Deitel <paul.deitel at deitel.com> wrote:

I am trying to chain together a series of animations. Is there a callback
mechanism of some sort that could be used to launch a new animation when
another animation completes?

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180420/ae56a3a2/attachment.html>