{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Render\n", "\n", "This is done through rendering the figure first and then reload it in a FuncAnimation with imshow.\n", "Therefore the zoom function is limited to the resolution of the figure." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from smpl_animation import animation\n", "from smpl import plot\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import tqdm" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## live-render" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib notebook \n", "plt.ioff()\n", "def update(a):\n", " plot.function(lambda x : a*x**2,xmin=0,xmax=5,init=True,tight=False)\n", "\n", "ani = animation.animate(update = update,frames=np.linspace(0,10,200), interval=10,blit=True)\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## pre-render" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib notebook \n", "plt.ioff()\n", "for a in tqdm.tqdm(np.linspace(0,10,200)):\n", " plot.function(lambda x : a*x**2,xmin=0,xmax=5,init=True,tight=False)\n", " animation.frame()\n", "\n", "#ani.save(\"test.gif\")\n", "ani = animation.animate(interval=10,blit=True)\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Save" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ani.save(\"test.gif\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from smpl_animation import animation\n", "from smpl import plot\n", "import numpy as np\n", "\n", "for a in np.linspace(0,10,200):\n", " plot.function(lambda x : a*x**2,xmin=0,xmax=5,init=True,tight=False)\n", " animation.frame()\n", "\n", "ani = animation.animate(interval=10,blit=True)\n", "ani.widget_gif()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.15" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": {}, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 4 }