0

I have a plot with 5 subplots, something like: enter image description here

I want the right most plot to have a little more space between the other 4. With GridSpec and GridSpecFromSubplotSpec, I have tried to adjust the wspace, as done in this SO answer. For some reason changing the wspace has 0 effect however.

from itertools import product
from matplotlib import pyplot as plt
from matplotlib.gridspec import GridSpec, GridSpecFromSubplotSpec


def no_axes():
    ax.get_xaxis().set_visible(False)
    ax.get_yaxis().set_visible(False)

fig = plt.figure(figsize=(12,6))
gs = GridSpec(2,3)
gs1 = GridSpecFromSubplotSpec(2, 2, subplot_spec=gs[:,:2])
gs2 = GridSpecFromSubplotSpec(2, 3, subplot_spec=gs[:,2], wspace=100000000)

# first 4 plots
for rc in product([0,1], repeat=2):
    ax = fig.add_subplot(gs1[rc])
    ax.plot()
    no_axes()

# last plot
ax = fig.add_subplot(gs2[:])
ax.plot()
no_axes()
plt.show()
Brian Barry
  • 439
  • 2
  • 17
  • I think you want to use this [answer](https://stackoverflow.com/a/51783672/7758804) instead. – Trenton McKinney May 18 '22 at 20:18
  • 1
    Use `gs = GridSpec(2, 3, wspace=0.5)` and remove `wspace=100000000` from `gs2`. See [code and plot](https://i.stack.imgur.com/NQ5Pj.png). `wspace` in `GridSpecFromSubplotSpec` defines the space between the plots in the subplots. `wspace` in `GridSpec` defines the space between the two sections. – Trenton McKinney May 18 '22 at 20:24

0 Answers0