Generation

generate functionTue, 25 Jul 2023

I need to graph the data of a sensor in real time

def graph_sensor(sensor_id): import matplotlib.pyplot as plt plt.ion() fig = plt.figure() ax = fig.add_subplot(111) fig.show() i = 0 x, y = [], [] while True: x.append(i) y.append(sensor_id.value) ax.plot(x, y, color='b') fig.canvas.draw() ax.set_xlim(left=max(0, i-50), right=i+50) time.sleep(0.1) i += 1

Want to kickstart your project?Use the new AI Studio to create your code