-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[ENH?] EngFormatter: add the possibility to remove the space before the SI prefix #6533
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
Comments
I would be OK with adding this option to the existing formatter. |
With the defaults |
Yes, unless it is actively broken we try to always preserve existing default functionality. I personally would expect there to be a space there, but see the use of adding the knob to change it. If you want to make the case that space should default to |
|
Oops, sorry for the misclick there. |
I'm totally fine with keeping the space separator as default, in particular because it's what typography says to be correct when there is a unit. Unfortunately, I didn't find any typographic reference about what's correct in the case with only a SI prefix (= without a unit symbol after). And it is less obvious to me that "1.23 µ" is definitively better (or at least less worse) than "1.23µ" from the typographic viewpoint¹. And as currently the default I guess the more rational thing to do is to keep the current behavior (corresponding to If this solution is fine, I will submit a PR with the proposed changes and defaults. By the way, in that case, should I wait for the PR #6014 to be merged to avoid having unnecessary conflicts to resolve²? ¹ : I'm not even sure one of the two solutions of considered correct by typographers… |
Just merged #6014 |
All I can find is the SI guide 6.2.6:
which gives no indication of what to do without a unit, but of course it also insists that should never happen... |
I've just submitted a PR, with what has been discussed here as default. |
Implemented in #6542. |
Discussing with some of my colleagues who are using other plotting softwares than Matplotlib, I noticed that their formatting of the engineering notation is a bit different from the one implemented in
ticker.EngFormatter
. Some softwares append directly the prefix/unit to the tick value (e.g. "1.23µs", vs "1.23 µs" with Matplotlib). I am not sure it is really OK from the (English) typography point of view but I guess they are doing this due to the rather limited ticklablel space.I wonder how interesting it may be to add such a possibility to the
EngFormatter
in Matplotlib. As some users may prefer "1.23µs" over "1.23 µs", I would say it's worth adding it toEngFormatter
.If it is added to
EngFormatter
, I guess the major pitfall would be the default values… IMO, the current behavior of Matplotlib is the best one whenEngFormatter
is instantiated with a unit. However, when it is instantatied without unit (unit=""
), I wouldn't be categorical about the fact that "1.23 µ" is better than "1.23µ". So I don't really know if one should use by default a space separator between the value and the prefix/unit, or not…I wrote a small demonstration of what could be easily done with the
EngFormatter
class (keeping the current Matplotlib behavior as the default one). It is > 100 lines because I directly copy-pasted the source code ofticker.EngFormatter
. I've put the changes between<ENH>
and<\ENH>
tags. NB: the code includes a bug fix similar to PR #6014 .The text was updated successfully, but these errors were encountered: