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 import animation
from smpl import plot
import matplotlib.pyplot as plt
import numpy as np
import tqdm

live-render

[5]:
%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:04<00:00, 48.51it/s]

Save

[4]:
ani.save("test.gif")
/usr/lib/python3.8/site-packages/matplotlib/animation.py:889: 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 have outputted the Animation using `plt.show()` or `anim.save()`.
  warnings.warn(
[ ]:

[ ]:

[ ]: