【问题标题】:Heat Maps Seaborn Annot Error热图 Seaborn Annot 错误
【发布时间】:2015-09-14 05:11:51
【问题描述】:

作为我之前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'

请提出解决办法?

【问题讨论】:

    标签: python matplotlib annotations seaborn


    【解决方案1】:

    annot=Trueheatmap 的参数,而不是pivot_table

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

    【讨论】:

      猜你喜欢
      • 2016-11-21
      • 2015-09-14
      • 2017-10-30
      • 2020-08-04
      • 2021-04-14
      • 2018-05-15
      • 2015-09-12
      • 2020-07-06
      • 2017-08-18
      相关资源
      最近更新 更多