我有一个图,该图包含三个子图,排列在同一列中。这些地块之一在右侧使用了3个y轴刺。我按照本教程在子图上插入多个右轴脊椎。
我的问题是,通过添加额外的刺,图中的所有子图在 x 方向上都变小了。这更改了所有三个子图的宽度,从而在其他子图的右侧保留了未使用的空间。
在y轴上添加额外的棘刺时,如何仅调整一个子图的宽度?
下面是一个简化的示例,它产生了此图中所示的相同问题
from matplotlib import pyplot as plt
# set up a set of three subplots
fig = plt.figure(figsize=(17, 11))
ax_1_l = fig.add_subplot(3,1,1)
ax_1_r = ax_1_l.twinx()
ax_2_l = fig.add_subplot(3,1,2)
ax_2_r = ax_2_l.twinx()
ax_3_l = fig.add_subplot(3,1,3)
ax_3_r = ax_3_l.twinx()
# add additional axes to the middle subplot as per tutorial
def make_patch_and_spines_invisible(ax):
ax.set_frame_on(True)
ax.patch.set_visible(False)
for sp in ax.spines.values():
sp.set_visible(False)
ax_2_r_2 = ax_2_l.twinx()
make_patch_and_spines_invisible(ax_2_r_2)
ax_2_r_2.spines['right'].set_position(('axes', 1.05))
ax_2_r_2.spines['right'].set_visible(True)
ax_2_r_3 = ax_2_l.twinx()
make_patch_and_spines_invisible(ax_2_r_3)
ax_2_r_3.spines['right'].set_position(('axes', 1.1))
ax_2_r_3.spines['right'].set_visible(True)
# display the plots
plt.tight_layout()
plt.show()
matplotlib版本2.1.2
慕的地6264312
HUX布斯
相关分类