Matplotlib子图:imshow + plot

时间:2017-04-11 17:48:01

标签: python matplotlib plot

我想创建一个如下图所示的图。图中有两个独特的图。 img1是使用plt.imshow()生成的,img2是使用plt.plot()生成的。我用于生成每个图的代码在下面提供

plt.clf()
plt.imshow(my_matrix)
plt.savefig("mymatrix.png")

plt.clf()
plt.plot(x,y,'o-')
plt.savefig("myplot.png")

img1中使用的矩阵是64x64img2的x轴(x=range(64))的范围相同。理想情况下,两个img2的x轴与img1的轴对齐。

重要的是要注意最终图像让人联想到seaborn的jointplot(),但下图中的边缘子图(img2)不显示分布图。

Ideal output with annotation

1 个答案:

答案 0 :(得分:1)

您可以使用make_axes_locatable的{​​{1}}功能沿中心mpl_toolkits.axes_grid1图的两个方向创建共享轴。

以下是一个例子:

imshow

enter image description here

相关问题