Рисунок не отображается в графике в реальном времени
Вот окно с рисунком, которое выглядит следующим образом. Вот мой код: [когда я запускаю свой код, в оболочке Python не было обнаружено ошибки, и окно рисунка также появилось. Но на этом рисунке окно данных не отображается (приходит только окно)]
import serial
import numpy as np
import matplotlib.pyplot as plt
from drawnow import *
literperhour=[]
arduinoData = serial.Serial('com9', 115200)
plt.ion()
cnt=0
def makeFig():
plt.ylim(80,90) #Set y min and max values
plt.title('My Live Streaming Sensor Data') #Plot the title
plt.grid(True) #Turn the grid on
plt.ylabel('literperhour') #Set ylabels
plt.plot(literperhour, 'ro-', label='L/hr') #plot the temperature
plt.legend(loc='upper left') #plot the legend
while True:
while (arduinoData.inWaiting()==0):
pass
arduinoString = arduinoData.readline()
dataArray = arduinoString.split(b',')
literperhour = ( dataArray[0])
drawnow(makeFig)
plt.pause(.000001) #Pause Briefly. Important to keep drawnow from crashing
cnt=cnt+1
if(cnt>50): #If you have 50 or more points, delete the first one from the array
literperhour.pop(0) #This allows us to just see the last 50 data points