仅在matplotlib中调整两个子图之间的距离 [英] Adjust the distance only between two subplots in matplotlib
本文介绍了仅在matplotlib中调整两个子图之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 3 个子图(3 行 1 列).我们可以使用 fig.subplots_adjust(hspace=0.2)
来调整子图之间的距离.这将改变所有情况下子图之间的距离.我怎样才能在情节 1 (311) & 之间有不同的距离?情节2(312)和情节2(312)&情节 3 (313)?
I have 3 subplots (3 rows and 1 column). We can use fig.subplots_adjust(hspace=0.2)
to adjust the distance between the subplots. this will change the distance between subplots for all case. How can I have different distance between plot 1 (311) & plot 2 (312), and plot 2 (312) & plot 3 (313)?
推荐答案
好问题.试试这个:
from mpl_toolkits.axes_grid1 import make_axes_locatable
ax1 = plt.subplot2grid((1,1), (0,0))
divider = make_axes_locatable(ax1)
ax2 = divider.append_axes("bottom", size="100%", pad=0.5)
ax3 = divider.append_axes("bottom", size="100%", pad=1)
然后你会得到:
这篇关于仅在matplotlib中调整两个子图之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文