How to make dynamic charts in Python 3?

1

I'm making a program for the Raspberry Pi that reads temperature sensors and stores those readings in a buffer. I need to make a dynamic graph that shows the current temperature / time relationship. I tried doing this using the matplotlib library, but I can not update this chart.

In the code below, when I use the append method I am adding the values obtained in the temperature reading.

import matplotlib.pyplot as plt

temperatura = [10, 20, 30 ,40 , 50 ,60 , 70, 80]

tempo = [1, 2, 3, 4, 5, 6, 7, 8]

plt.plot(tempo, temperatura )

plt.ylabel('Temperatura (C°)')

plt.xlabel('Tempo (S)')

plt.show()

temperatura.append(90)

tempo.append(9)

plt.plot(tempo, temperatura )

plt.show()

When you run the program, the graph with the initial values is displayed, but only when you close the graph does the other graph open with the updated values!

    
asked by anonymous 08.10.2018 / 16:26

0 answers