-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Simplify decade up- and down-rounding, and symmetrize expansion of degenerate log scales. #13413
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
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.
Seems right except for the doc string issue.
6ac5d20
to
3b5dc4d
Compare
lib/matplotlib/ticker.py
Outdated
|
||
def _decade_less(x, base): | ||
""" | ||
Return the smallest integer power of *base* that's less than *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.
Return the smallest integer power of *base* that's less than *x*. | |
Return the largest integer power of *base* that's less than *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.
thanks, fixed
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 one suggestion on a docstring.
Instead of `decade_up` and `decade_down`, use more explicit `_decade_less`, `_decade_less_equal`, etc. which moreover also handle negative values (used by the symlog scale). Previously, `semilogx([.1, .1], [1, 2])` would autoscale the x-axis from a bit less than 0.1 to a bit more than 1, because 0.1 == 10**-1 so decade_down(0.1) would use `floor(-1) == -1` and return 0.1, while decade_up(0.1) would return 1. With this PR, `semilogx([.1, .1], [1, 2])` instead autoscales the x-axis from a bit less than 0.01 to a bit more than 1 (i.e. one decade on each side), which seems more logical.
3b5dc4d
to
46db9e2
Compare
Should be ready to go now. |
…and symmetrize expansion of degenerate log scales.
Something went wrong ... Please have a look at my logs. |
…413-on-v3.1.x Backport PR #13413 on branch v3.1.x (Simplify decade up- and down-rounding, and symmetrize expansion of degenerate log scales.)
Instead of
decade_up
anddecade_down
, use more explicit_decade_less
,_decade_less_equal
, etc. which moreover also handlenegative values (used by the symlog scale).
Previously,
semilogx([.1, .1], [1, 2])
would autoscale the x-axis froma bit less than 0.1 to a bit more than 1, because 0.1 == 10**-1 so
decade_down(0.1) would use
floor(-1) == -1
and return 0.1, whiledecade_up(0.1) would return 1.
With this PR,
semilogx([.1, .1], [1, 2])
instead autoscales the x-axisfrom a bit less than 0.01 to a bit more than 1 (i.e. one decade on each
side), which seems more logical.
PR Summary
PR Checklist