Created
July 18, 2021 20:52
-
-
Save mwaskom/7bf5ee9c474a6d3c9b223188a96e6e43 to your computer and use it in GitHub Desktop.
Put a title on the right y axis of a matplotlib axes using the set_title API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib as mpl | |
import matplotlib.pyplot as plt | |
f, ax = plt.subplots(figsize=(5, 5)) | |
ax.set_title("Col title", y=1) | |
title = ax.set_title( | |
"Row title", loc="right", y=.5, | |
rotation=270, ha="left", va="center", | |
) | |
offset_trans = mpl.transforms.ScaledTranslation( | |
mpl.rcParams["axes.titlepad"] / 72, 0, ax.figure.dpi_scale_trans | |
) | |
title.set_transform(ax.transAxes + offset_trans) |
Author
mwaskom
commented
Jul 18, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment