Render¶
This is done through rendering the figure first and then reload it in a FuncAnimation with imshow. Therefore the zoom function is limited to the resolution of the figure.
[1]:
from smpl_animation import animation
from smpl import plot
import matplotlib.pyplot as plt
import numpy as np
import tqdm
live-render¶
[2]:
%matplotlib notebook
plt.ioff()
def update(a):
plot.function(lambda x : a*x**2,xmin=0,xmax=5,init=True,tight=False)
ani = animation.animate(update = update,frames=np.linspace(0,10,200), interval=10,blit=True)
plt.show()
pre-render¶
[3]:
%matplotlib notebook
plt.ioff()
for a in tqdm.tqdm(np.linspace(0,10,200)):
plot.function(lambda x : a*x**2,xmin=0,xmax=5,init=True,tight=False)
animation.frame()
#ani.save("test.gif")
ani = animation.animate(interval=10,blit=True)
plt.show()
100%|██████████| 200/200 [00:05<00:00, 36.70it/s]
Save¶
[4]:
ani.save("test.gif")
MovieWriter ffmpeg unavailable; using Pillow instead.
/github/home/.cache/pypoetry/virtualenvs/smpl-animation-VRc_1PH3-py3.8/lib/python3.8/site-packages/matplotlib/animation.py:879: UserWarning: Animation was deleted without rendering anything. This is most likely not intended. To prevent deletion, assign the Animation to a variable, e.g. `anim`, that exists until you output the Animation using `plt.show()` or `anim.save()`.
warnings.warn(
[5]:
from smpl_animation import animation
from smpl import plot
import numpy as np
for a in np.linspace(0,10,200):
plot.function(lambda x : a*x**2,xmin=0,xmax=5,init=True,tight=False)
animation.frame()
ani = animation.animate(interval=10,blit=True)
ani.widget_gif()
MovieWriter ffmpeg unavailable; using Pillow instead.
[5]:
[ ]:
[ ]:
[ ]: