【发布时间】:2018-08-10 09:18:13
【问题描述】:
我不确定为什么我的小部件上没有显示图表线。
x 轴应随时间移动,当我打印应绘制的 y 值 (Temp) 时,新值会按预期出现。但是,绘图上没有显示线/点。
我在过去的绘图中遇到过类似的问题,通过更改绘制点的样式(即使用 'r*' 使点可见红星)解决了这个问题。我不确定如何在这段代码中实现同样的事情。
import matplotlib.pyplot as plt
import numpy
import datetime
import matplotlib.animation as animation
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
def animate(i):
Time = []
Temp = []
x = datetime.datetime.now()
y = numpy.random.randint(48,52)
Time.append(x)
Temp.append(int(y))
ax1.plot(Time,Temp)
print(Temp)
ani = animation.FuncAnimation(fig,animate, interval=1000)
plt.show()
【问题讨论】:
标签: python-3.x animation matplotlib plot widget