import sqlite3
import matplotlib.animation as animation
import matplotlib.pyplot as plt
def animate(i):
con = sqlite3.connect('newbase1.db')
c = con.cursor()
c.execute('SELECT Cell_1_V,Cell_2_V,Cell_1_T, time_stamp FROM Measurements')
data = c.fetchall()
Cell_1_V = []
Cell_2_V = []
Cell_1_T = []
tim = []
for row in data:
Cell_1_V.append(row[0])
Cell_2_V.append(row[1])
Cell_1_T.append(row[2])
tim.append(row[3])
fig , (sb1,sb2) = plt.subplots(nrows=2,ncols= 1)
sb1.set_xlabel("TIME---->")
sb1.set_ylabel("VOLTAGE--->")
sb2.set_xlabel("TIME---->")
sb2.set_ylabel("TEMP--->")
sb1.plot(tim,Cell_1_V,label='Cell_1_V')
sb2.plot(tim, Cell_1_T, label='Cell_1_T')
sb1.legend(loc='upper right')
sb2.legend(loc='upper right')
ani = animation.FuncAnimation(plt.gcf(), animate, interval=500)
plt.tight_layout()
plt.show()
The above is the code where I am trying to animate both subplots in the same figure but all i get is an empty plot. Any help would be appreciated.
Thanks in advance.
