I am trying to run a measurement, measuring a temperature over time, using QCoDeS measurement drivers. I would like to view a live plotting of the data. Preferably using Matplotlib.Animation package. How best to do this?
I have tried the below but the graph does not update.
Etime = ElapsedTimeParameter('Etime')
meas = Measurement()
meas.register_parameter(Etime)
meas.register_parameter(T1, setpoints=[Etime])
fig, ax = plt.subplots()
xdata, ydata = [], []
ln, = ax.plot([], [], 'ro')
def init():
ax.set_xlabel('Time (s)')
ax.set_ylabel('Temperature (K)')
return ln,
def update(now, temp):
xdata.append(now)
ydata.append(temp)
ln.set_data(xdata, ydata)
return ln,
ani = FuncAnimation(fig, update, len(ydata), init_func=init, blit=True)
with meas.run() as datasaver:
Etime.reset_clock()
for _ in range(20):
temp = T1()
now = Etime()
update(now, temp)
datasaver.add_result((T1, temp), (Etime, now))
plt.show()
time.sleep(1)
dataset = datasaver.dataset