简体   繁体   English

仅调整matplotlib中两个子图之间的距离

[英]Adjust the distance only between two subplots in matplotlib

I have 3 subplots (3 rows and 1 column). 我有3个子图(3行1列)。 We can use fig.subplots_adjust(hspace=0.2) to adjust the distance between the subplots. 我们可以使用fig.subplots_adjust(hspace=0.2)来调整子图之间的距离。 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)? 如何在图1(311)和图2(312)以及图2(312)和图3(313)之间有不同的距离?

Good question. 好问题。 Try this: 尝试这个:

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)

Then you would get: 然后你会得到:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM