I'm having problems with Matplotlib animation. I've taken code directly from https://www.geeksforgeeks.org/matplotlib-animation-funcanimation-class-in-python/ and have installed ffmeg, but am getting an error message. The error message and the code is below, would be grateful for some help.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation
from matplotlib.animation import FuncAnimation
fig = plt.figure()
axis = plt.axes(xlim =(0, 4),
ylim =(-2, 2))
line, = axis.plot([], [], lw = 3)
def init():
line.set_data([], [])
return line,
def animate(i):
x = np.linspace(0, 4, 1000)
y = np.sin(2 * np.pi * (x - 0.01 * i))
line.set_data(x, y)
return line,
anim = FuncAnimation(fig, animate,
init_func = init,
frames = 200,
interval = 20,
blit = True)
anim.save('continuousSineWave.mp4',
writer = 'ffmpeg', fps = 30)
Top of error message:
MovieWriter stderr:
dyld: Library not loaded: @rpath/libopenh264.5.dylib
Referenced from: /opt/anaconda3/lib/libavcodec.58.54.100.dylib
Reason: image not found