Skip to content
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

Add nonsingular to the locator base class, and use it in set_*lim too. #13409

Merged
merged 1 commit into from
Feb 11, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 11, 2019

Currently, some Locator subclasses define a nonsingular() method, which
is used by autoscale_view() in case the autoscaling would return a
degenerate interval, to expand the view limits; autoscale_view() falls
back on a default in case the nonsingular() method does not exist. Move
that default to the Locator base class.

Also use that nonsingular() method when a degenerate interval is passed
to set_xlim/set_ylim/etc., instead of always hardcoding the same linear
expansion.

(Semantically the correct place for this nonsingular() method is
probably on the scale class rather than on the locator...)

The changes to test_ticker are due to the fact that the default
expansion is now by 5%, so there's no offset text anymore in the
left=right=123 case (as it gets expanded to 116.85, 129.15).


e.g. for xscale("log"); xlim(.1, .1) one used to get
old
but one now gets
new
(in both cases with the "Attempting to set identical left == right == 0.1 results in singular transformations; automatically expanding." warning).

May be worth doing the same on colorbars, but their locator isn't set yet when the expansion needs to be done :/

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 force-pushed the nonsingular branch 3 times, most recently from c86ce72 to 20d49f8 Compare February 11, 2019 15:10
doc/api/next_api_changes/2019-02-12-AL.rst Outdated Show resolved Hide resolved
Currently, some Locator subclasses define a nonsingular() method, which
is used by autoscale_view() in case the autoscaling would return a
degenerate interval, to expand the view limits; autoscale_view() falls
back on a default in case the nonsingular() method does not exist.  Move
that default to the Locator base class.

Also use that nonsingular() method when a degenerate interval is passed
to set_xlim/set_ylim/etc., instead of always hardcoding the same linear
expansion.

(Semantically the correct place for this nonsingular() method is
probably on the scale class rather than on the locator...)

The changes to test_ticker are due to the fact that the default
expansion is now by 5%, so there's no offset text anymore in the
left=right=123 case (as it gets expanded to 116.85, 129.15).
@QuLogic QuLogic merged commit ed8e70e into matplotlib:master Feb 11, 2019
@QuLogic QuLogic added this to the v3.1.0 milestone Feb 11, 2019
@anntzer anntzer deleted the nonsingular branch February 11, 2019 23:11
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