Matplotlib: Annotate Subplots in a Figure with A, B, C [duplicate] Matplotlib: Annotate Subplots in a Figure with A, B, C [duplicate] python python

Matplotlib: Annotate Subplots in a Figure with A, B, C [duplicate]


If you want the annotation relative to the subplot then plotting it using ax.text seems the most convenient way to me.

Consider something like:

import numpy as npimport matplotlib.pyplot as pltimport stringfig, axs = plt.subplots(2,2,figsize=(8,8))axs = axs.flatfor n, ax in enumerate(axs):    ax.imshow(np.random.randn(10,10), interpolation='none')        ax.text(-0.1, 1.1, string.ascii_uppercase[n], transform=ax.transAxes,             size=20, weight='bold')

enter image description here