带数值轴的Seaborn热图

时间:2018-02-28 01:41:51

标签: python matplotlib seaborn

我想用第二个图表覆盖热图(KDEplot,但是对于这个例子,我将使用散点图,因为它显示了相同的问题)。

Seaborn热图具有分类轴,因此用数字轴覆盖图表并不能正确排列两个图表。

示例:

df = pd.DataFrame({2:[1,2,3],4:[1,3,5],6:[2,4,6]}, index=[3,6,9])
df

    2   4   6
3   1   1   2
6   2   3   4
9   3   5   6

fig, ax1 = plt.subplots(1,1)
sb.heatmap(df, ax=ax1, alpha=0.1)

enter image description here

用散点图覆盖它:

fig, ax1 = plt.subplots(1,1)
sb.heatmap(df, ax=ax1, alpha=0.1)
ax1.scatter(x=5,y=5, s=100)
ax1.set_xlim(0,10)
ax1.set_ylim(0,10)

有没有办法说服热图将列和索引值用作数值?

enter image description here

1 个答案:

答案 0 :(得分:3)

你无法“说服” $Array.Remove('server*') 不要产生分类情节。最好使用另一个使用数字轴的图像图。例如,使用heatmap图。当然,假设列和行是均匀分布的。然后,

pcolormesh

产生

enter image description here