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

Skip to content

Commit 5e3bede

Browse files
authored
Merge pull request #14624 from anntzer/loglocatororder
FIX: axis inversion with loglocator and logitlocator.
2 parents 0290a7e + 9bc8097 commit 5e3bede

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

doc/api/next_api_changes/2019-03-04-AL.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,3 @@ properties of the `.Collection` object:
4747
While this seems complicated, the logic is simply to use the information from
4848
the object that are in data space for the limits, but not information that is
4949
in physical units.
50-
51-
LogLocator.nonsingular now maintains the orders of its arguments
52-
````````````````````````````````````````````````````````````````
53-
54-
It no longer reorders them in increasing order. The new behavior is consistent
55-
with MaxNLocator.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
API changes
2+
```````````
3+
4+
``Locator.nonsingular`` (introduced in mpl 3.1), ``DateLocator.nonsingular``, and
5+
``AutoDateLocator.nonsingular`` now returns a range ``v0, v1`` with ``v0 <= v1``.
6+
This behavior is consistent with the implementation of ``nonsingular`` by the
7+
``LogLocator`` and ``LogitLocator`` subclasses.

lib/matplotlib/dates.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,8 +1117,9 @@ def nonsingular(self, vmin, vmax):
11171117
"""
11181118
Given the proposed upper and lower extent, adjust the range
11191119
if it is too close to being singular (i.e. a range of ~0).
1120-
11211120
"""
1121+
if vmax < vmin:
1122+
vmin, vmax = vmax, vmin
11221123
unit = self._get_unit()
11231124
interval = self._get_interval()
11241125
if abs(vmax - vmin) < 1e-6:
@@ -1336,6 +1337,8 @@ def tick_values(self, vmin, vmax):
13361337
def nonsingular(self, vmin, vmax):
13371338
# whatever is thrown at us, we can scale the unit.
13381339
# But default nonsingular date plots at an ~4 year period.
1340+
if vmax < vmin:
1341+
vmin, vmax = vmax, vmin
13391342
if vmin == vmax:
13401343
vmin = vmin - DAYS_PER_YEAR * 2
13411344
vmax = vmax + DAYS_PER_YEAR * 2

lib/matplotlib/ticker.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,9 +2495,7 @@ def view_limits(self, vmin, vmax):
24952495
return vmin, vmax
24962496

24972497
def nonsingular(self, vmin, vmax):
2498-
swap_vlims = False
24992498
if vmin > vmax:
2500-
swap_vlims = True
25012499
vmin, vmax = vmax, vmin
25022500
if not np.isfinite(vmin) or not np.isfinite(vmax):
25032501
vmin, vmax = 1, 10 # Initial range, no data plotted yet.
@@ -2515,8 +2513,6 @@ def nonsingular(self, vmin, vmax):
25152513
if vmin == vmax:
25162514
vmin = _decade_less(vmin, self._base)
25172515
vmax = _decade_greater(vmax, self._base)
2518-
if swap_vlims:
2519-
vmin, vmax = vmax, vmin
25202516
return vmin, vmax
25212517

25222518

0 commit comments

Comments
 (0)