In a matplotlib figure I would like to enumerate all (sub)plots with a), b), c) and so on. Is there a way to do this automatically?
So far I use the individual plots
A super quick way to do this is to take advantage of the fact that chr()
casts integers to characters. Since a-z fall in the range 97-122, one can do the following:
import matplotlib.pyplot as plt
fig,axs = plt.subplots(2,2)
for i,ax in enumerate(axs.flat, start=97):
ax.plot([0,1],[0,1])
ax.text(0.05,0.9,chr(i)+')', transform=ax.transAxes)
which produces: