{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# matplotlib animate test\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.animation as animation\n\n# Adapted from\n# https://matplotlib.org/gallery/animation/basic_example.html\n\n\ndef _update_line(num):\n line.set_data(data[..., :num])\n return line,\n\n\nfig, ax = plt.subplots()\ndata = np.random.RandomState(0).rand(2, 25)\nline, = ax.plot([], [], 'r-')\nax.set(xlim=(0, 1), ylim=(0, 1))\nani = animation.FuncAnimation(fig, _update_line, 25, interval=100, blit=True)\nplt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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" } }, "nbformat": 4, "nbformat_minor": 0 }