Matplotlib: panel label out of the box, above the ylabel
matplotlib, python
Solution
values outside of `[0, 1]` are valid.
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
for i, label in enumerate(('A', 'B', 'C', 'D')):
ax = fig.add_subplot(2,2,i+1)
ax.text(-0.1, 1.15, label, transform=ax.transAxes,
fontsize=16, fontweight='bold', va='top', ha='right')
plt.show()
Problem
I have been using matplotlib for all my publication-use figures, and one question is: how to I place the panel labels that is out of the box? The tutorial is shown here, with the code and result: ``` import numpy as np import matplotlib.pyplot as plt fig = plt.figure() for i, label in enumerate(('A', 'B', 'C', 'D')): ax = fig.add_subplot(2,2,i+1) ax.text(0.05, 0.95, label, transform=ax.transAxes, fontsize=16, fontweight='bold', va='top') plt.show() ``` But the panel label is only at the corner of the bounding box, not out side of the box and above the y axis label (which is the usual way), like this: Any input would be appreciated. Thanks!