# PyPlot.jl reduce white space after tight_layout()

Can I reduce the amount of whitespace between subplots after the plot?

Please note I need AA and BB to have linked X, Y axes and the same sizes with a shared colorbar, and that AA, BB and CC need to have a shared X axis.

Here’s the MWE

``````fig, ax = plt.subplots(4, 1, gridspec_kw=Dict("height_ratios" => [1,4,4,1]),
figsize=(10,5))
ax[1].plot(rand(10))
ax[1].set_title("CC")
ax[2].imshow(rand(10,10), aspect="auto")
ax[2].sharex(ax[1])
ax[2].set_title("BB")
imlast = ax[3].imshow(rand(10,10), aspect="auto")
ax[3].set_title("AA")
ax[3].set_xlabel("AA xlabel")
ax[3].sharex(ax[2])
map(x->x.tick_params(labelbottom=false), ax[1:end-2])
fig.colorbar(imlast, cax=ax[4], orientation="horizontal", label="Log₁₀ S/m")
fig.tight_layout()
``````

The number of rows can vary, and `sharex` in the initial `subplots()` invocation above isn’t appropriate because of the `cax=ax[4]`

Take a look at constrained_layout guide with padding and spacing. I hope, it will help.

1 Like

Thanks, turns out that `tigh_layout()` even without constrained layout, can take an `h_pad` argument which can reduce the minimum space.