Skip to content

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

Merged
merged 1 commit into from
Feb 24, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 11, 2019

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.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • 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

@anntzer anntzer changed the title Simplify decade up- and down-rounding. Simplify decade up- and down-rounding, and symmetrize expansion of degenerate log scales. Feb 11, 2019
Copy link
Member

@jklymak jklymak left a 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.

@jklymak jklymak added this to the v3.1.0 milestone Feb 16, 2019

def _decade_less(x, base):
"""
Return the smallest integer power of *base* that's less than *x*.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Return the smallest integer power of *base* that's less than *x*.
Return the largest integer power of *base* that's less than *x*.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed

Copy link
Member

@tacaswell tacaswell left a 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.
@anntzer
Copy link
Contributor Author

anntzer commented Feb 24, 2019

Should be ready to go now.

@tacaswell tacaswell merged commit 98ba02f into matplotlib:master Feb 24, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Feb 24, 2019
…and symmetrize expansion of degenerate log scales.
@lumberbot-app
Copy link

lumberbot-app bot commented Feb 24, 2019

Something went wrong ... Please have a look at my logs.

@anntzer anntzer deleted the decade-updown branch February 24, 2019 19:30
dstansby added a commit that referenced this pull request Feb 24, 2019
…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.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants