Relative Content

Tag Archive for pythonanimation

Varying the number of points per frame in FuncAnimation

I’m trying to create a 3D animation of the moon’s orbit around the Earth. Each point in the time vector (‘times’) that is used to create the orbit data is not equally spaced, however, I would like to have each frame in the animation be equally spaced in time so that the orbit is continuous. (The time vector is generated using an integration technique that cannot keep the interval between times constant.) I figured that the best way to do this would be to vary the number of points plotted per frame, but I can’t figure out how to implement that using FuncAnimation.

Modify Python Code FuncAnimation for changing color and markerplot of animated graph

import numpy as np import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation fig = plt.figure() axis = plt.axes(xlim=(-4, 4), ylim=(-3, 3)) line, = axis.plot([], [], lw=2) def init(): line.set_data([], []) return line, def animate(i): y = omega[i]*np.sin(x) line.set_data(x, y) return line, x = np.arange(-4, 4+0.001, 0.001) domega = 0.25 omega = np.arange(-3, 3+domega, domega) anim […]