I have some issue to do a graph and I was wondering if someone could help me please. Here is my situation :
I've got two arrays : one for temperature values and another for the time.
My goal is to do a graph representing the temperature in function of time that refresh automatically each time a value is appended in my arrays (every 0.2 seconds).
Here is a code that I tried but it didn't work at all. I'm not at my ease at all with Python and plot so sorry for all these mistakes
import matplotlib.pyplot as plt
import random
import time
# My arrays are empty at the beginning
raw_temp_bme = []
temps = []
plt.ion()
fig, ax = plt.subplots(figsize=(8, 6))
line1, = ax.plot(temps, raw_temp_bme, "r")
plt.title("Température du BME680 en fonction du temps")
plt.xlabel("Temps en ms")
plt.ylabel("Température en °C")
start_time = time.time()
while True:
# I append my two arrays
raw_temp.append(round(random.uniform(15.0, 30.0), 2))
temps.append(round(time.time() - start_time, 2))
line1.set_xdata(temps)
line1.set_ydata(raw_temp_bme)
fig.canvas.draw()
fig.canvas.flush_events()
time.sleep(0.2)
Here is a screenshot of what I've got
Nothing appears in my graph.
Thank you so much in advance