如何解决移除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')
图像输出
我使用st.pyplot在Streamlit dashbaord上渲染
任何帮助将不胜感激。
PS在Jupyter笔记本中正确显示
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。