As of v3.3 you can now set these with the loc
argument of set_xlabel
and set_ylabel
:
import matplotlib.pyplot as plt# Left plotoptions = ['left', 'center', 'right']fig, axs = plt.subplots(len(options), 1, constrained_layout=True)for ax, loc in zip(axs, options): ax.plot([1, 2, 3]) ax.set_xlabel(f'xlabel loc={loc!r}', loc=loc)
# Right plotoptions = ['bottom', 'center', 'top']fig, axs = plt.subplots(1, len(options), constrained_layout=True)for ax, loc in zip(axs, options): ax.plot([1, 2, 3]) ax.set_ylabel(f'ylabel loc={loc!r}', loc=loc)