[英]Set the y-axis to scale in a Seaborn heat map
I currently have a dataframe, df:我目前有一个数据框,df:
In [1]: df
Out [1]:
one two
1.5 11.22
2 15.36
2.5 11
3.3 12.5
3.5 14.78
5 9
6.2 26.14
I used this code to get a heat map:我使用此代码获取热图:
In [2]:
plt.figure(figsize=(30, 7))
plt.title('Test')
ax = sns.heatmap(data=df, annot=True,)
plt.xlabel('Test')
ax.invert_yaxis()
value = 6
index = np.abs(df.index - value).argmin()
ax.axhline(index + .5, ls='--')
print(index)
Out [2]:
I am looking for the y-axis, instead, to automatically scale and plot the df[2] values in their respective positions on the full axis.相反,我正在寻找 y 轴来自动缩放和绘制 df[2] 值在全轴上各自的位置。 For example, there should be a clear empty space between 3.5 and 5.0 as there aren't any values - I want the values in between on the y-axis with 0 value against them.例如,在 3.5 和 5.0 之间应该有一个明显的空白空间,因为没有任何值 - 我希望 y 轴上的值与它们之间的值为 0。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.