I have a figure that displays 12 subplots that are organised into 3 rows and 4 columns. I'd like each subplot to have it's own title and an centred title that is above each row.
The code below displays this for the first row. However, I'd like to generate the same suptitle for rows 2-3.
I have played around with plt.text but was wondering if there's a more efficient way to achieve this?
import matplotlib.pyplot as plt
fig, ((ax1, ax2, ax3, ax4),
(ax5, ax6, ax7, ax8),
(ax9, ax10, ax11, ax12)) = plt.subplots(3, 4)
ax1.set_title('Fig1', ha = 'center')
ax2.set_title('Fig2', ha = 'center')
ax3.set_title('Fig3', ha = 'center')
ax4.set_title('Fig4', ha = 'center')
ax5.set_title('Fig5', ha = 'center')
ax6.set_title('Fig6', ha = 'center')
ax7.set_title('Fig7', ha = 'center')
ax8.set_title('Fig8', ha = 'center')
ax9.set_title('Fig9', ha = 'center')
ax10.set_title('Fig10', ha = 'center')
ax11.set_title('Fig11', ha = 'center')
ax12.set_title('Fig12', ha = 'center')
plt.suptitle('Row 1')
#plt.suptitle('Row 2')
fig.tight_layout()
plt.draw()
Output:
As you can see, the suptitle is displayed for the first row but I'm unable to repeat that for the 2nd and 3rd rows.