I am currently working on a raspberry pi project and I want to dynamically plot a graph while the data is displaying in the terminal. From the code I have, the graph only updates if I close the window and it reopens with an updated version of the graph. `Thank you
import matplotlib.pyplot as plt`
from time import sleep
from Adafruit_CCS811 import Adafruit_CCS811
ccs = Adafruit_CCS811()
while not ccs.available():
pass
temp = (ccs.calculateTemperature() / 3.2) - 32.0
ccs.tempOffset = temp - 25.0
while(True):
if ccs.available():
temp = ccs.calculateTemperature()
if not ccs.readData():
print ("CO2: ", ccs.geteCO2(), "ppm, TVOC: ", ccs.getTVOC(), " temp: ", temp)
plt.plot([ccs.geteCO2(), ccs.getTVOC(), temp])
plt.pause(0.05)
plt.show()
else:
print ("ERROR!")
while(True):
pass
sleep(2)