I currently try to use matplotlib.animation.FuncAnimation to create Dynamic candlestick, but when I Use the example code like this link.
My python version is 3.7.1
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
fig, ax = plt.subplots()
xdata, ydata = [], []
ln, = plt.plot([], [], 'ro')
def init():
ax.set_xlim(0, 2*np.pi)
ax.set_ylim(-1, 1)
return ln,
def update(frame):
xdata.append(frame)
ydata.append(np.sin(frame))
ln.set_data(xdata, ydata)
return ln,
ani = FuncAnimation(fig, update, frames=np.linspace(0, 2*np.pi, 128),
init_func=init, blit=True)
plt.show()
But as images, I get an empty figure. enter image description here
I don't know what's happened.
So I come to here ask your help.
All you guys responses are very helpful to me, It means a lot. Thanks.