python gridspec,共享x轴和y轴时出现问题

python gridspec,共享x轴和y轴时出现问题,python,matplotlib,Python,Matplotlib,我正在使用gridspec进行多面板绘图,但有一些问题。我希望每行共享不同的y轴,每列共享不同的x轴。或者,换句话说,每行共享x,每列共享y。我还想为每个轴添加一个标签。下面是我所说的示例,以及使其减去我想要的轴标签的代码: 资料来源: 但是,我不能确切地使用这个实现,因为我使用subplot2grid,因为我需要选择每个绘图的特定位置和尺寸。我尝试在subplot2grid调用中使用sharex=ax1和sharey=ax1,但没有成功。以下是我的代码的相关部分: ax1 = plt.subp

我正在使用gridspec进行多面板绘图,但有一些问题。我希望每行共享不同的y轴,每列共享不同的x轴。或者,换句话说,每行共享x,每列共享y。我还想为每个轴添加一个标签。下面是我所说的示例,以及使其减去我想要的轴标签的代码: 资料来源:

但是,我不能确切地使用这个实现,因为我使用subplot2grid,因为我需要选择每个绘图的特定位置和尺寸。我尝试在subplot2grid调用中使用sharex=ax1和sharey=ax1,但没有成功。以下是我的代码的相关部分:

ax1 = plt.subplot2grid((8,8), (2,0), colspan=2, rowspan=2)
ax2 = plt.subplot2grid((8,8), (4,0), colspan=2, rowspan=2)
ax3 = plt.subplot2grid((8,8), (6,0), colspan=2, rowspan=2)
ax4 = plt.subplot2grid((8,8), (2,2), colspan=2, rowspan=2)
ax5 = plt.subplot2grid((8,8), (4,2), colspan=2, rowspan=2)
ax6 = plt.subplot2grid((8,8), (2,4), colspan=2, rowspan=2)
ax7 = plt.subplot2grid((8,8), (1,0), colspan=2, rowspan=1)
ax8 = plt.subplot2grid((8,8), (1,2), colspan=2, rowspan=1)
ax9 = plt.subplot2grid((8,8), (1,4), colspan=2, rowspan=1)
ax10 = plt.subplot2grid((8,8), (2,6), colspan=1, rowspan=2)

与普通子地块不同,使用sharex/sharey=ax和subplot2grid或GridSpec的子地块不仅共享范围,还共享刻度

要分别为每个子批次配置刻度,您需要plt.setpax.getxticklabels,visible=False,请参阅以了解更多详细信息。

在ax2或任何其他调用的定义中使用例如sharex=ax1和/或sharey=ax1应该对我有用。
ax1 = plt.subplot2grid((8,8), (2,0), colspan=2, rowspan=2)
ax2 = plt.subplot2grid((8,8), (4,0), colspan=2, rowspan=2)
ax3 = plt.subplot2grid((8,8), (6,0), colspan=2, rowspan=2)
ax4 = plt.subplot2grid((8,8), (2,2), colspan=2, rowspan=2)
ax5 = plt.subplot2grid((8,8), (4,2), colspan=2, rowspan=2)
ax6 = plt.subplot2grid((8,8), (2,4), colspan=2, rowspan=2)
ax7 = plt.subplot2grid((8,8), (1,0), colspan=2, rowspan=1)
ax8 = plt.subplot2grid((8,8), (1,2), colspan=2, rowspan=1)
ax9 = plt.subplot2grid((8,8), (1,4), colspan=2, rowspan=1)
ax10 = plt.subplot2grid((8,8), (2,6), colspan=1, rowspan=2)