热图Seaborn Annot错误

时间:2015-06-27 08:47:34

标签: python matplotlib annotations seaborn

作为我之前question

的延伸

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

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'

请建议可能有什么问题?

1 个答案:

答案 0 :(得分:1)

annot=Trueheatmap的参数,而不是pivot_table

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