【发布时间】:2021-05-10 11:50:14
【问题描述】:
在 Python/matplotlib 程序中,我试图更改动画图中标记的大小,以使用 python 显示数组的大小。
在此代码中,如果标记移动到 x[i],y[i],则标记的大小应为 s[i]。这意味着标记点 x[i],y[i] 的大小应该显示 s[i] 在该点的值。任何关于如何制作这样一个情节的建议将不胜感激。
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
x = np.linspace(0, 10, 100)
y = np.sin(x)
s = np.random.randint(10,20,100)
fig, ax = plt.subplots()
scat, = ax.plot(x[0], y[0], 'o', markersize = s[0])
def update(i, x, y, scat):
scat.set_data(x[i], y[i])
scat.axes.axis([0, 10, -1, 1])
return scat,
ani = animation.FuncAnimation(fig, update, len(x), fargs=[x,y, scat],
interval=25, blit=False)
plt.show()*
【问题讨论】:
标签: python matplotlib animation