'How to create a figure where one axis is placed between and under 2 alligned axes?

I want to create a figure with the layout seen in the image below. Ideally, all the axes must have same dimensions (sorry my paint skills are not very good).

enter image description here

I have found the following tutorial: https://matplotlib.org/stable/tutorials/intermediate/arranging_axes.html, but the solutions seem very complicated. I was wondering if there is an easier way to do this. Thanks in advance.



Solution 1:[1]

Arguably the easiest way to achieve that is by using GridSpec:

import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec

gs = GridSpec(3, 4)
fig = plt.figure(tight_layout=True)
ax1 = fig.add_subplot(gs[0, :2])
ax2 = fig.add_subplot(gs[0, 2:])
ax3 = fig.add_subplot(gs[1, :2])
ax4 = fig.add_subplot(gs[1, 2:])
ax5 = fig.add_subplot(gs[2, 1:-1])

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Davide_sd