我有以下代码在Python中绘制3D图
data = # taken from an SQL query in (x, y, z) format #
x, y, z = zip(*data)
z = map(float, z)
grid_x, grid_y = np.mgrid[min(x):max(x):100j, min(y):max(y):100j]
grid_z = griddata((x, y), z, (grid_x, grid_y), method='cubic')
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot_surface(grid_x, grid_y, grid_z, cmap=plt.cm.Spectral)
plt.show()
我希望该图每1分钟更新一次。我可以每1分钟使用一个线程从表中获取数据,但无法更新绘图。
你能帮我一个建议吗?
提前致谢!
经过一番研究,我找到了使用matplotlib.animation做到这一点的方法。
下面的Youtube链接有很大帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句