import matplotlib.pyplot as plt import numpy as np import serial, sys import matplotlib.pyplot as plt import time port = "COM3" baudrate = 9600 #ser = serial.Serial(port,baudrate,timeout=0.001) """ while True: data = ser.read(1) data+= ser.read(ser.inWaiting()) sys.stdout.write(str(data)) sys.stdout.flush() """ """ l = 16 x = np.arange(-l,l,.2) y= np.zeros(x.shape) print(x.shape) print(y.shape) plt.ion() fig,ax = plt.subplots() line, = ax.plot(x,y) plt.show() np.delete(y,0) np.append(y,1) line.set_ydata(y) fig.canvas.draw() print(y.shape) index=0 while 1: time.sleep(0.01) #update vectors np.delete(y,0) np.append(y, np.sin(0.2*index)) #int.from_bytes(data, "big") line.set_ydata(y) fig.canvas.draw() index+=1 """ plt.axis([0, 10, -1, 1]) index=0 while 1: #switch to while there is data y = np.sin(index) plt.scatter(index, y) index+=0.1 plt.pause(0.001) if (index==10): index=0 plt.show()