I'm trying to make live stock heatmap, which updates it's data every 0.2 seconds with stock ticker/price annotations on it. But when I started code for first time, i found that Seaborn puts another annotations without deleting the previous one every time it is called. Can someone tell me how to delete previous annotation or edit already existing annotations?
def animate(i):
#getting price datas from sql
mkdatac.execute(stc, (chs,))
pricerows = mkdatac.fetchall()
for row in pricerows:
prices = (np.asarray(pricerows).reshape(1, 2))
print(prices)
mkdatac.execute(stt, (chs,))
stcoderows = mkdatac.fetchall()
for row in stcoderows:
symbols = (np.asarray(stcoderows).reshape(1, 2))
print(symbols)
#making labels(annotation)
labels = (np.asarray(["{0} \n {1:.2f}".format(symb,value)
for symb, value in zip(symbols.flatten(),
prices.flatten())])
).reshape(1,2)
#drawing heatmap
sns.heatmap(prices, annot=labels, fmt="", cmap='RdYlGn', linewidths=0.30, ax=ax, cbar=False)