Make the size of a heatmap bigger with seaborn

后端 未结 3 741
粉色の甜心
粉色の甜心 2021-01-31 07:22

I create a heatmap with seaborn

df1.index = pd.to_datetime(df1.index)
df1 = df1.set_index(\'TIMESTAMP\')
df1 = df1.resample(\'30min\').mean()
ax = sns.heatmap(         


        
3条回答
  •  时光取名叫无心
    2021-01-31 08:08

    You could alter the figsize by passing a tuple showing the width, height parameters you would like to keep.

    import matplotlib.pyplot as plt
    
    fig, ax = plt.subplots(figsize=(10,10))         # Sample figsize in inches
    sns.heatmap(df1.iloc[:, 1:6:], annot=True, linewidths=.5, ax=ax)
    

    EDIT

    I remember answering a similar question of yours where you had to set the index as TIMESTAMP. So, you could then do something like below:

    df = df.set_index('TIMESTAMP')
    df.resample('30min').mean()
    fig, ax = plt.subplots()
    ax = sns.heatmap(df.iloc[:, 1:6:], annot=True, linewidths=.5)
    ax.set_yticklabels([i.strftime("%Y-%m-%d %H:%M:%S") for i in df.index], rotation=0)
    

    For the head of the dataframe you posted, the plot would look like:

提交回复
热议问题