Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix axis inversion with loglocator and logitlocator. #14624

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
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions doc/api/next_api_changes/2019-03-04-AL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,3 @@ properties of the `.Collection` object:
While this seems complicated, the logic is simply to use the information from
the object that are in data space for the limits, but not information that is
in physical units.

LogLocator.nonsingular now maintains the orders of its arguments
````````````````````````````````````````````````````````````````

It no longer reorders them in increasing order. The new behavior is consistent
with MaxNLocator.
7 changes: 7 additions & 0 deletions doc/api/next_api_changes/2019-06-25-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
API changes
```````````

``Locator.nonsingular`` (introduced in mpl 3.1), ``DateLocator.nonsingular``, and
``AutoDateLocator.nonsingular`` now returns a range ``v0, v1`` with ``v0 <= v1``.
This behavior is consistent with the implementation of ``nonsingular`` by the
``LogLocator`` and ``LogitLocator`` subclasses.
5 changes: 4 additions & 1 deletion lib/matplotlib/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,9 @@ def nonsingular(self, vmin, vmax):
"""
Given the proposed upper and lower extent, adjust the range
if it is too close to being singular (i.e. a range of ~0).

"""
if vmax < vmin:
vmin, vmax = vmax, vmin
unit = self._get_unit()
interval = self._get_interval()
if abs(vmax - vmin) < 1e-6:
Expand Down Expand Up @@ -1336,6 +1337,8 @@ def tick_values(self, vmin, vmax):
def nonsingular(self, vmin, vmax):
# whatever is thrown at us, we can scale the unit.
# But default nonsingular date plots at an ~4 year period.
if vmax < vmin:
vmin, vmax = vmax, vmin
if vmin == vmax:
vmin = vmin - DAYS_PER_YEAR * 2
vmax = vmax + DAYS_PER_YEAR * 2
Expand Down
4 changes: 0 additions & 4 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2495,9 +2495,7 @@ def view_limits(self, vmin, vmax):
return vmin, vmax

def nonsingular(self, vmin, vmax):
swap_vlims = False
if vmin > vmax:
swap_vlims = True
vmin, vmax = vmax, vmin
if not np.isfinite(vmin) or not np.isfinite(vmax):
vmin, vmax = 1, 10 # Initial range, no data plotted yet.
Expand All @@ -2515,8 +2513,6 @@ def nonsingular(self, vmin, vmax):
if vmin == vmax:
vmin = _decade_less(vmin, self._base)
vmax = _decade_greater(vmax, self._base)
if swap_vlims:
vmin, vmax = vmax, vmin
return vmin, vmax


Expand Down