我的计划是使用4GridSpec(4,1)
网格规范来创建一个4x4子空间网格。我想在每行4个子图的x轴上添加一条水平线。我看着matplotlib.lines.Line2D但没能真正弄明白。有什么建议吗?我试图在视觉上简化图片,这样它看起来不像16个单独的图形。在
在下面的图片中,我只有前2个网格规格,但我希望它提供了一个更好的想法,我希望实现。在
谢谢!干杯
代码(图形部分):
#---the graph---
fig = plt.figure(facecolor='white')
gs1 = GridSpec(4,1)
gs1.update(left = 0.15, right = .3375 , wspace=0.02)
ax1 = plt.subplot(gs1[3,0])
ax2 = plt.subplot(gs1[2,0])
ax3 = plt.subplot(gs1[1,0])
ax4 = plt.subplot(gs1[0,0])
gs2 = GridSpec(4,1)
gs2.update(left = 0.3875, right = .575, wspace=.25)
ax1 = plt.subplot(gs2[3,0])
ax2 = plt.subplot(gs2[2,0])
ax3 = plt.subplot(gs2[1,0])
ax4 = plt.subplot(gs2[0,0])
show()
基本上,我们的想法是画一条线,让这条线延伸到轴的当前视图之外,在下面的例子中,我用红色绘制这条线,以便更好地看到它。在
另外,您的8个绘图可以在嵌套循环中绘制,这样可以更好地组织代码,并使“跨子绘图的公共线”更易于实现:
相关问题 更多 >
编程相关推荐