[英]Plot lineplot on top of seaborn heatmap using same axes
I have seaborn heatmap and I would like to plot a lineplot on top of it while using the same x and y axis that the heatmap is using.我有 seaborn 热图,我想在 plot 顶部绘制一个线图,同时使用与热图相同的 x 和 y 轴。
I expected the line to behave like in this post and take up most of the space of the heatmap, but instead the output I got was the following plot where it only occupied a small section of the heatmap.我希望这条线的行为与这篇文章中的一样,并占据热图的大部分空间,但我得到的 output 是下面的 plot ,它只占据了热图的一小部分。 How can I make the line take up most of the space in the heatmap?
如何使线条占据热图中的大部分空间?
Below is the minimal working example that produced the plot I linked above.下面是生成我上面链接的 plot 的最小工作示例。
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
num = 11
a = np.eye(num)
x = np.round(np.linspace(0, 1, num=num), 1)
y = np.round(np.linspace(0, 1, num=num), 1)
df = pd.DataFrame(a, columns=x, index=y)
f, ax = plt.subplots()
ax = sns.heatmap(df, cbar=False)
ax.axes.invert_yaxis()
sns.lineplot(x=x, y=y)
plt.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.