Skip to content

Instantly share code, notes, and snippets.

View Kappie's full-sized avatar

Geert Kapteijns Kappie

View GitHub Profile
@Kappie
Kappie / add_labels.py
Last active April 3, 2020 16:44
Automatically add figure labels (a), (b), (c), etc. to axes. Labels are located at the top-left of the axis, at the same horizontal position as the y-label.
def add_labels(axes, style=r'(%s)'):
"""
Adds figure labels (a), (b), (c), etc. to axes.
Must be called after plt.tight_layout().
"""
alphabet = 'abcdefghijkl'
labels = [style % letter for letter in alphabet]
# EXTREME hack alert.