- {
- “cells”: [
- {
“cell_type”: “markdown”, “metadata”: {}, “source”: [
“# Parametric”
]
}, {
“cell_type”: “code”, “execution_count”: 1, “metadata”: {}, “outputs”: [
- {
- “data”: {
- “text/plain”: [
“<Figure size 640x480 with 3 Axes>”
]
}, “metadata”: {}, “output_type”: “display_data”
}
], “source”: [
“import numpy as npn”, “import matplotlib.pyplot as pltn”, “from matplotlib.animation import PillowWritern”, “import animatplot as ampn”, “n”, “n”, “def psi(t):n”, “ x = tn”, “ y = np.sin(t)n”, “ return x, yn”, “n”, “n”, “t = np.linspace(0, 2 * np.pi, 25)n”, “x, y = psi(t)n”, “X, Y = amp.util.parametric_line(x, y)n”, “n”, “timeline = amp.Timeline(t, "s", 24)n”, “n”, “ax = plt.axes(xlim=[0, 7], ylim=[-1.1, 1.1])n”, “block1 = amp.blocks.Line(X, Y, ax=ax)n”, “# or equivalentlyn”, “# block1 = amp.blocks.ParametricLine(x, y, ax=ax)n”, “n”, “anim = amp.Animation([block1], timeline)n”, “n”, “# Your standard matplotlib stuffn”, “plt.title("Parametric Line")n”, “plt.xlabel("x")n”, “plt.ylabel(r"y")n”, “n”, “# Create Interactive Elementsn”, “anim.toggle()n”, “anim.timeline_slider()n”, “n”, “anim.save("parametric.gif", writer=PillowWriter(fps=5))n”, “plt.show()”
]
}, {
“cell_type”: “raw”, “metadata”: {
“raw_mimetype”: “text/restructuredtext”
}, “source”: [
“.. image:: parametric.gif”
]
}
], “metadata”: {
“celltoolbar”: “Raw Cell Format”, “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.6.5”
}
}, “nbformat”: 4, “nbformat_minor”: 2
}