I'd like to add a table to the right of two subplots using matplotlib. I tried the following code but it aligned the table with only one subplot...
import matplotlib.pyplot as plt
import numpy as np
t = np.linspace(-1,1,100)
fig, axs = plt.subplots(2, 1, constrained_layout=True)
ax1, ax2 = axs
ax1.plot(t, t**2)
ax1.set_title('One plot')
ax1.set_xlabel('Time')
ax1.set_ylabel('Amplitude')
ax1.legend()
ax2.plot(t, t**3)
ax2.set_title('Another plot')
ax2.set_xlabel('Time')
ax2.set_ylabel('Amplitude')
clust_data = np.random.random((10,3))
collabel=("col 1", "col 2", "col 3")
the_table = plt.table(cellText=clust_data,
colLabels=collabel,
loc='right')
I also tried to use Gridspec but without success. Thanks for your help!