GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — LearnPythonStats/anim_plot6.py at master · elthe/LearnPythonStats Expand file tree/ Copy pathanim_plot6.pyMore file actions 39 lines (29 loc) · 977 Bytes / Copy pathanim_plot6.pyFile metadata and controls39 lines (29 loc) · 977 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 #!/usr/bin/env python # -*- coding: utf-8 -*- """ matplotlib.animation使用示例。 """ import numpy as np from matplotlib import pyplot as plt from matplotlib import animation # first set up the figure, the axis, and the plot element we want to animate fig = plt.figure() ax1 = fig.add_subplot(2, 1, 1, xlim=(0, 2), ylim=(-4, 4)) ax2 = fig.add_subplot(2, 1, 2, xlim=(0, 2), ylim=(-4, 4)) line, = ax1.plot([], [], lw=2) line2, = ax2.plot([], [], lw=2) def init(): line.set_data([], []) line2.set_data([], []) return line, line2 # animation function. this is called sequentially def animate(i): x = np.linspace(0, 2, 100) y = np.sin(2 * np.pi * (x - 0.01 * i)) line.set_data(x, y) x2 = np.linspace(0, 2, 100) y2 = np.cos(2 * np.pi * (x2 - 0.01 * i)) * np.sin(2 * np.pi * (x - 0.01 * i)) line2.set_data(x2, y2) return line, line2 anim1 = animation.FuncAnimation(fig, animate, init_func=init, frames=50, interval=10) plt.show() |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |