Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adjust the distance only between two subplots in matplotlib

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)?

like image 639
DurgaDatta Avatar asked Dec 18 '13 16:12

DurgaDatta


1 Answers

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:

enter image description here

like image 55
Skyler Avatar answered Sep 28 '22 18:09

Skyler