python 图标题上移_将标题移动到Seaborn热图的colorbar上方

我在Seaborn做了一个热图,我有一个相应的水平色条。我在colorbar中添加了一个标题,但是,当我真正想要它在colorbar上方时,它会出现在colorbar下面。有什么原因我可以改变吗?是否可以更改标题的字体大小和颜色栏上标签的大小?在fig, ax = plt.subplots(figsize=(30,12))

graph = sns.heatmap(df_pivot, cmap="Blues", linecolor="white", linewidths=0.1,

cbar_kws={"orientation": "horizontal", "shrink":0.40, "aspect":40, "label": "Number of accidents"})

ax.set_title("Number of traffic accidents per day & hour combination",

fontsize=30, fontweight="bold")

from matplotlib import rcParams

rcParams['axes.titlepad'] = 70 # Space between the title and graph

locs, labels = plt.yticks() # Rotating row labels

plt.setp(labels, rotation=0) # Rotating row labels

ax.xaxis.tick_top() # x axis on top

ax.xaxis.set_label_position('top')

graph.tick_params(axis='both',labelsize=15) # Tick label size

graph

这就是目前为止的情况。我希望“事故数量”的标题在颜色条上方,但在热图下方。我希望颜色条和热图一样宽。在

7266d58d16abe54d5edba56f25b24dd1.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值