热图 Seaborn 注释错误 [英] Heat Maps Seaborn Annot Error

查看:28
本文介绍了热图 Seaborn 注释错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为我之前的问题的延伸

使用相同的数据集,我无法完成注释.

With same data set I am not able to get the annotation done.

import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
sns.set()

df = pd.read_csv('heat_map_data.csv')

df3 = df.copy()
for c in ['Place','Name']:
    df3[c] = df3[c].astype('category')

sns.heatmap(df3.pivot_table(index='Place', columns='Name', values='00:00:00', annot=True) )

plt.show() 

错误:

Traceback (most recent call last):
  File "heatmap_sns.py", line 13, in <module>
    sns.heatmap(df3.pivot_table(index='Place', columns='Name', values='00:00:00', annot=True) )
TypeError: pivot_table() got an unexpected keyword argument 'annot'

请提出可能的修复方法?

Please suggest what could be the fix ?

推荐答案

annot=Trueheatmap 的参数,而不是 pivot_table:

annot=True is an argument of heatmap, not pivot_table:

sns.heatmap(df3.pivot_table(index='Place', columns='Name', values='00:00:00'), 
            annot=True)

这篇关于热图 Seaborn 注释错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆