It is easier to create two separate GridSpec for this. Some good options are also available here
As you mentioned, you need the first 3 subplots to have 0.05 hspace, while the next one (between 3rd and 4th) to have 0.5 hspace. So, the first Grdspec will have hspace of 0.05, while the next one will have 0.5 hspace. Also, I have removed the x-axis for the first group and have a shared x-axis. This is shown below in an example of 4 subplots example...
import matplotlib.pyplot as plt
# Use two gridspecs to have specific hspace
gs_top = plt.GridSpec(nrows=4, ncols=1, hspace=0.05) ## HSPACE for top 3
gs_base = plt.GridSpec(nrows=4, ncols=1, hspace=0.5) ##HSPACE for last one
fig = plt.figure()
# The first 3 shared axes
ax = fig.add_subplot(gs_top[0,:]) # Create the first one, then add others...
other_axes = [fig.add_subplot(gs_top[i,:], sharex=ax) for i in range(1, 3)]
bottom_axes = [ax] + other_axes
# Hide shared x-tick labels
for ax in bottom_axes[:-1]:
plt.setp(ax.get_xticklabels(), visible=False)
# Plot data
for ax in bottom_axes:
data = np.random.normal(0, 1, np.random.randint(10, 500)).cumsum()
ax.plot(data)
ax.margins(0.05)
#Finally plot the last one, with hspace of 0.5 - gs_base
finalax = fig.add_subplot(gs_base[-1,:])
finalax.plot(np.random.normal(0, 1, 1000).cumsum())
plt.show()
Plot
