移除Seaborn Heatmap Streamlit上方和下方的空白

问题描述

我正在用seaborn生成热图并将其显示在Streamlit仪表板上。生成的图像上方和下方都有很多空白。

#creating heatmap
df= df[['x','y','z']]

df_temp =  df.pivot_table(index=x,columns=y,values= z)
                    

plt.figure(figsize=(13,80))
clr = sns.color_palette("RdBu",7)

ax = sns.heatmap(df_temp,annot=True,fmt='.1f',cmap=clr,cbar=False);

#set x axis label on top
ax.xaxis.set_ticks_position('top')

# split axes of heatmap to put colorbar
ax_divider = make_axes_locatable(ax)

# define size and padding of axes for colorbar
cax = ax_divider.append_axes('top',size = '0.2%',pad = '1%')

# make colorbar for heatmap. 
# Heatmap returns an axes obj but you need to get a mappable obj (get_children)
colorbar(ax.get_children()[0],cax = cax,orientation = 'horizontal')

# locate colorbar ticks
cax.xaxis.set_ticks_position('top')

图像输出

Image with space on top of chart

我使用st.pyplot在Streamlit dashbaord上渲染

任何帮助将不胜感激。

PS在Jupyter笔记本中正确显示

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...