问题描述
我正在用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 (将#修改为@)