What is the best way to create a (3,3) subplot matrix in python with the following catch:
- first column contains 3 subplots
- second column contains 3 subplots
- third column contains 2 subplots
The last two subplots should have equal size. This means they will meet in the middle of the middle plot for the other two columns.
I tried to do this with gridspec but did not managed so far.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import gridspec
# generate some data
x = np.arange(0, 10, 0.2)
y = np.sin(x)
# plot it
fig = plt.figure(figsize=(8, 6))
gs = gridspec.GridSpec(3, 3)
ax0 = plt.subplot(gs[0])
ax0.plot(x, y)
ax1 = plt.subplot(gs[1])
ax1.plot(y, x)
ax3 = plt.subplot(gs[3])
ax3.plot(y, x)
ax4 = plt.subplot(gs[4])
ax4.plot(y, x)
ax6 = plt.subplot(gs[6])
ax6.plot(y, x)
ax7 = plt.subplot(gs[7])
ax7.plot(y, x)
plt.tight_layout()
plt.savefig('grid_figure.png')
plt.show()