Repository navigation
correctly format ticklabels when EngFormatter is used with usetex = True - #12847
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 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
ScalarFormattercorrectly formats the numbers in ticklabels using$signs when used withusetex=TruebutEngFormatterdoesn'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 usesEngFormatterbut the other one doesn't (see the example below). This PR fixes that by correctly formatting the numbers in ticklabels whenEngFormatteris used.One workaround (as suggested in a related issue #11586 (comment)) is to turn off
usetexfor the axis that usesScalarFormatterso 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