-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
added property usemathtext to EngFormatter #12856
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
We use the convention that underscore attributes are private. So no one should be accessing that attribute, so I don’t think you should add it until we provide a public interface. |
following in the footsteps of |
This comment is written with respect to the first commit here. This would at least allow to work around the issue by
So even if the argument is that "private" should not be used by anyone, this is still a useful change. Also, I'm not actually convinced that the general approach of #12847 is useful for the EngFormatter
This will now lead to the numbers being rendered in a different font than the unit prefixes. I can hardly imagine that this is what people want by default, and it's especially annoying if there isn't even any workaround for it. |
I agree with both the views presented here. I think I have stepped into something which is far beyond my reach... I will wait for all the experienced core developers to weigh-in before making any changes. I will be happy to implement the suggestions on how to move forward. Please feel free to take this over if it would be easier that way. |
This comment is written with respect to the second commit here. This goes in the right direction IMO. But... the Maybe some more bikeshedding is needed here? |
Would the following approach work? (1) not treating usetex and usemathtext as being equivalent inside |
Possibly... I'm not having the complete overview of As of now I think I would be happy with either of (a) leaving EngFormatter untouched, i.e. revert #12847, (b) Get the first commit here in, in case people think that the different fonts for numbers and unit prefix are acceptable. |
out of those two options I think I would prefer to go with (b) since that allows for the most flexible behavior (for now). I will wait for comments from other core/experienced developers before proceeding. Ideally I would like to fix |
should I proceed by reverting the change in #12847? I would appreciate some advice from core/experienced developers. Thanks! |
(sorry started working on this yesterday, and got distracted) Well, this is a fun pickle of inconsistent APIs. To check my understanding:
Did I get the facts/history right? |
Yes! |
May I just add that allowing for the |
I think(??) the end target would be to have
? |
Thanks all for the feedback. I will implement the suggestions. |
I have made the changes as suggested. Please note that I have assumed an equivalence between A positive implication of this decision: |
lib/matplotlib/ticker.py
Outdated
@@ -1200,7 +1200,8 @@ class EngFormatter(Formatter): | |||
24: "Y" | |||
} | |||
|
|||
def __init__(self, unit="", places=None, sep=" "): | |||
def __init__(self, unit="", places=None, sep=" ", usetex=None, |
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.
Please make the new arguments keyword-only (sep=" ", *, usetex=None, ...
).
lib/matplotlib/ticker.py
Outdated
@@ -1226,10 +1227,42 @@ def __init__(self, unit="", places=None, sep=" "): | |||
* ``sep="\\N{THIN SPACE}"`` (``U+2009``); | |||
* ``sep="\\N{NARROW NO-BREAK SPACE}"`` (``U+202F``); | |||
* ``sep="\\N{NO-BREAK SPACE}"`` (``U+00A0``). | |||
` |
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.
the extra, spurious backtick here makes the doc build unhappy
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.
modulo CI.
I am glad this came to a conclusion! Does this same public API also exist on Could you please add a |
Added a what's new entry. I don't think there is a public API for controling the Thank you everyone involved in this discussion for guiding me through this! |
Thanks! |
…856-on-v3.1.x Backport PR #12856 on branch v3.1.x (added property usemathtext to EngFormatter)
@pharshalp Did you end up adding a public API for |
If not, I might be able to take a crack at it over winter break. |
@mattdutson I didn't end up adding a public API for
Please feel free to take a crack at it. Thanks! |
PR Summary
Based on #12847 (comment)
Adding._usetex
as an attribute for EngFormatter so as to allow the user to set it toFalse
(resulting in numbers being displayed using text font instead of math font). This will be consistent with whatScalarFormatter
allows.PR Checklist