Skip to content

Commit

Permalink
More flexible subplot lettering (#94)
Browse files Browse the repository at this point in the history
* More flexible subplot lettering

* Fix linter
  • Loading branch information
jbusecke committed Mar 24, 2021
1 parent 504ada9 commit 131faed
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions xarrayutils/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def axis_arrow(ax, x_loc, text, arrowprops={}, **kwargs):
)


def letter_subplots(axes, start_idx=0, box_color=None, **kwargs):
def letter_subplots(axes, start_idx=0, box_color=None, labels=None, **kwargs):
"""Adds panel letters in boxes to each element of `axes` in the
upper left corner.
Expand All @@ -122,12 +122,16 @@ def letter_subplots(axes, start_idx=0, box_color=None, **kwargs):
Starting index in the alphabet (e.g. 0 is 'a').
box_color : type
Color of the box behind each letter (the default is None).
labels: list
List of strings used as labels (if None (default), uses lowercase alphabet followed by uppercase alphabet)
**kwargs : type
kwargs passed to matplotlib.axis.text
"""
if labels is None:
labels = list(string.ascii_letters)

for ax, letter in zip(axes.flat, list(string.ascii_lowercase)[start_idx:]):
for ax, letter in zip(axes.flat, labels[start_idx:]):
t = ax.text(
0.1,
0.85,
Expand Down

0 comments on commit 131faed

Please sign in to comment.