我正在更新圖表,但無法加入散點圖,有人可以幫我嗎?我不明白,如何實作它。
from matplotlib import pyplot as plt
from matplotlib.animation import FuncAnimation
fig = plt.figure()
ax = fig.add_subplot()
line = ax.plot([],[])[0]
x = []
y = []
scat = ax.scatter(x,y,c='Red')
def animate(i):
x.append(i)
y.append((-1)**i)
line.set_data(x, y)
ax.relim()
ax.autoscale_view()
return [line]
anim = FuncAnimation(fig, animate, frames=200, interval=100, blit=True)
plt.show()
我想添加點,它們的坐標只在 X 中改變,Y 應該是 0。

uj5u.com熱心網友回復:
這里必須解決幾個問題。您必須更新散點圖,這是一個
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/447247.html
標籤:python-3.x matplotlib matplotlib-动画
上一篇:來自pandas系列值計數的matplotlib條形圖
下一篇:pyplot3dz軸對數圖
