如何删除 Seaborn(实时)热图中的注释?

时间:2021-04-26 04:24:57

标签: python matplotlib seaborn matplotlib-animation

我正在尝试制作实时股票热图,它每 0.2 秒更新一次数据,上面带有股票代码/价格注释。但是当我第一次开始写代码的时候,我发现Seaborn每次调用时都会放另一个注释而不删除前一个。有人能告诉我如何删除以前的注释或编辑现有的注释吗?

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)

0 个答案:

没有答案
相关问题