Created
December 17, 2020 20:22
-
-
Save justinmklam/d7a064f5b47e4aaf8fb01b3b5425524f to your computer and use it in GitHub Desktop.
Matplotlib legend locations. Source: https://stackoverflow.com/a/43439132
This file contains hidden or 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
# Outside top right | |
l1 = plt.legend(bbox_to_anchor=(1.04,1), borderaxespad=0) | |
# Outside bottom right | |
l2 = plt.legend(bbox_to_anchor=(1.04,0), loc="lower left", borderaxespad=0) | |
# Outside center right | |
l3 = plt.legend(bbox_to_anchor=(1.04,0.5), loc="center left", borderaxespad=0) | |
# Outside top single row | |
l4 = plt.legend(bbox_to_anchor=(0,1.02,1,0.2), loc="lower left", | |
mode="expand", borderaxespad=0, ncol=3) | |
# Outside bottom right | |
l5 = plt.legend(bbox_to_anchor=(1,0), loc="lower right", | |
bbox_transform=fig.transFigure, ncol=3) | |
# Inside center left | |
l6 = plt.legend(bbox_to_anchor=(0.4,0.8), loc="upper right") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment