-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
correctly format ticklabels when EngFormatter is used with usetex = True #12847
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
Conversation
I think I agree w. codecov that you should have an image test for this, but others may disagree. But otherwise looks good to me! |
I have added a test which doesn't rely on image comparison, I hope that's ok. |
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.
Subject to CI pass.
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.
Subject to CI
There is a difference between the use of tex for rendering fonts in a figure, which is controlled by the There is a premise inside the I do not agree to this premise. Those are really separate things. Now the |
I see your point. For now will it be sufficient to add |
Well, it would be wrong IMO, but at least consistent with ScalarFormatter and hence allow to work around it. So if noone wants to tackle the underlying problem of |
ok. I will push a temporary fix (adding |
I don’t see that adding a private method to give users more control is quite the right solution here! |
PR Summary
ScalarFormatter
correctly formats the numbers in ticklabels using$
signs when used withusetex=True
butEngFormatter
doesn't do so (hence the numbers show up in "text font" instead of "math font"). This results in inconsistent fonts if one of the axes usesEngFormatter
but the other one doesn't (see the example below). This PR fixes that by correctly formatting the numbers in ticklabels whenEngFormatter
is used.One workaround (as suggested in a related issue #11586 (comment)) is to turn off
usetex
for the axis that usesScalarFormatter
so that both the axes show ticklables in "text font" (For example --ax.yaxis.get_major_formatter()._usetex = False
).I think the solution suggested in this PR is much better since it results in consistent (and expected) behavior across different Formatters without having to use the non-public attribute
._usetex
.Before the PR:
After the PR:
PR Checklist
[ ] Has Pytest style unit tests[ ] New features are documented, with examples if plot related[ ] Documentation is sphinx and numpydoc compliant[ ] Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)[ ] Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way