-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX symlog scale now shows negative labels. #7337
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
For information, I am uncovering major problems in the ticker module. |
The formatter returned empty strings for negative value. closes #7146
elif x > 10000: | ||
s = '%1.0e' % x | ||
s = '%1.0e' % abs(x) |
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.
Something is still wrong--this doesn't make sense. It looks like the solution is to remove all of these abs
calls, and instead set x = abs(x)
right after saving the sign of x, a few lines above.
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.
Also, if the LogFormatter is going to handle negative values, this should be explained in the docstring.
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 LogFormatter is used with the SymmetricalLogLocator so it should (and probably always has) deal with negative value. But the LogLocator doesn't deal with negative values.
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.
I'll fix the abs stuff. Another solution is not to deal with the sign as it is done in the other formatter (or remove the explicit dealing with sign as it is done right now, I am not sure why)
Honestly, I think this whole part should be refactored and rewritten. I just wanted a quick and easy fix in this PR, as this is a critical bug for 2.0 and don't think we should refactor all this before the release.
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.
I think that dealing with the sign separately is a simplification; all the logic can work with conditions based on x>0
, as appropriate for logs. The generalization to make it usable for symlog is then just a matter of stripping off the sign at the start and putting it back at the end.
@efiring Can you re-review? |
Note: the patch for #7202 relies on this fix. |
FIX symlog scale now shows negative labels. Conflicts: lib/matplotlib/tests/test_ticker.py
Back ported to v2.x as e2de966. |
Thanks @efiring for merging! |
FIX symlog scale now shows negative labels. Conflicts: lib/matplotlib/tests/test_ticker.py
FIX symlog scale now shows negative labels. Conflicts: lib/matplotlib/tests/test_ticker.py
The formatter returned empty strings for negative value.
closes #7146