python - 如何删除 Seaborn(实时)热图中的注释?
问题描述
我正在尝试制作实时股票热图,它每 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)
解决方案
推荐阅读
- reactjs - 在 ReactJS 中导出后如何修改 axios 实例?
- css - Angular 中的侧导航面板
- rust - 比较 Ref 和 PartialEq 的内容
- django - Django 阻止超级用户查看 /change/ 页面中的数据
- tensorflow - 通过视频对象检测的边界框坐标
- python - 如何从非零元素的索引字典创建稀疏 numpy 数组?
- java - 找到请求类型 [java.lang.Long] 的 HttpMessageConverter
- javascript - Javascript/jQuery:如何从 HTML 字符串(event.target 的值)中提取属性/属性?
- c++ - 实时线程中的 ZeroMQ inproc PubSub send() 调用会导致严重阻塞吗?
- r - 如何减少三次方程的最大峰值(拟合)