-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Contour fixes/improvements #16171
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contour fixes/improvements #16171
Conversation
The previous heuristic was wrong for "wide" fonts, and was also overly complicated, as the Text class already has the relevant functionality.
(locate_label has no division, print_label explicitly suppresses the division by zero warning.)
f11f36a
to
113c652
Compare
Contour plots now default to using ScalarFormatter | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Pass ``fmt="%1.3f"`` to the countouring call to restore the old default label |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass ``fmt="%1.3f"`` to the countouring call to restore the old default label | |
Pass ``fmt="%1.3f"`` to the contouring call to restore the old default label |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It says coutouring now...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
second try...
PR Summary
Closes #16153, and does some more.
Three fixes/improvements to contour labeling, grouped together to minimize baseline images changes.
Code-wise I think this is ready for review, but marking as draft PR just so that I can still have a look at whether we can combine/delete some of the baseline images.I also took advantage of the baseline regen to merge two tests (test_contour_manual_labels and test_contour_label_size_color).Commit 1: Improve estimation of label text width, as explained in #16153.
Commit 2: Remove
matplotlib/lib/matplotlib/contour.py
Lines 564 to 567 in 262c67f
Commit 3: Switch the default formatter to ScalarFormatter and use format_ticks to format all ticks at once, allowing the reuse of auto-precision choice by ScalarFormatter. Ultimately we could even use someting like #12473 (reusing colorbar logic to format values) but this shouldn't change any baseline images as none of them uses log scale (so they would still all use ScalarFormatter).
Commit 4: Update baseline images all at once. See the precision change and unicode minus sign in e.g. test_contour/contour_test_label_transforms.png and the tighter fit of labels in e.g. test_patheffects/collection.png.
I'm not sure why CI is failing even though I updated the baseline images locally, though.Figured out the test failure.PR Checklist