0

As per the title, I'm wondering if it is possible to pause a matplotlib ArtistAnimation. I know it is possible to pause when using FuncAnimation, but I am not sure that that method can be applied to an ArtistAnimation.

An example of a working ArtistAnimation without pausing is

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

fig, ax = plt.subplots()
ax.set(xlim=(0, 2*np.pi), ylim=(-1, 1))

x = np.linspace(0, 2*np.pi, 100)

ims = []  # Blank list that will contain all frames
for frame in range(50):
    line, = ax.plot(x, np.sin(x + 0.1*frame), color='k')
    # Add new element to list with everything that changes between frames
    ims.append([line])

anim = ArtistAnimation(fig, ims, interval=100)
Community
  • 1
  • 1
hugke729
  • 351
  • 3
  • 7

1 Answers1

0

The following is not a complete solution, but maybe some way toward one. It requires IPython be used.

Using anim as defined in the question, I can enter anim._stop() to pause the animation. I can also use anim._step() as needed to see the next frames.

I'm not sure if it's possible to get the animation to start running again after these calls.

hugke729
  • 351
  • 3
  • 7