Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
add itemboxalign option to legend constructor#29197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Adding itembox alignment option for legends | ||
--------------------------------------------------------- | ||
`~.Legend` previously always aligns items using the "baseline" option, which results in | ||
Check warning on line 4 in doc/users/next_whats_new/legend_itemboxalign.rst
| ||
the appearance of vertical centering of the artist and label for multi-line labels. | ||
This is sometimes hard to read. The introduction of the `itemboxalign` parameter allows | ||
the user to change this behavior and choose a different desired vertical alignment. | ||
.. plot:: | ||
:include-source: true | ||
:alt: A legend with artist and label aligned to 'top' rather than 'baseline' | ||
import matplotlib.pyplot as plt | ||
fig, ax = plt.subplots(1, 2) | ||
ax[0].plot([5, 2, 8], label='long\nlabel') | ||
ax[0].plot([4, 9, 1], label='another\nlong\nlabel') | ||
ax[0].legend(title="align=baseline (default)") | ||
ax[1].plot([5, 2, 8], label='long\nlabel') | ||
ax[1].plot([4, 9, 1], label='another\nlong\nlabel') | ||
ax[1].legend(title="align=top", itemboxalign='top') | ||
plt.show() |
Uh oh!
There was an error while loading.Please reload this page.