【发布时间】:2020-12-15 01:34:42
【问题描述】:
为了比较,我想在 matplotlib 中创建一个包含 2x2 子图的图形,使用类似:
fig = plt.figure(figsize=(15,15))
ax1 = fig.add_subplot(2, 2, 1)
ax1.plot(x1,y1)
ax2 = fig.add_subplot(2, 2, 2)
ax2.plot(x2,y2)
ax3 = fig.add_subplot(2, 2, 3)
ax3.plot(x3,y3)
ax4 = fig.add_subplot(2, 2, 4)
ax4.plot(x4,y4)`enter code here`
fig.tight_layout(pad=3.0)
但是,让我们假设应该在subplot(2,2,2) 中绘制的数据需要一个不连续的 x 轴。到目前为止,我发现所有使用中断的 x 轴绘制数据的方法都依赖于将数据拆分并将其绘制到不同的子图中,正如这个接受的 stackoverflow 答案中所解释的那样:
https://stackoverflow.com/questions/32185411/break-in-x-axis-of-matplotlib
因此,我正在寻找一种方法来将 2x2 子图中的不连续 x 轴显示为 subplot(2,2,2) 以及包含 no 不连续轴的 3 个轴。
下面的草图说明了这个想法: sketch subsubplot in a subplot
有什么建议吗?
【问题讨论】:
标签: python matplotlib plot subplot