Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9783e24

Browse filesBrowse files
committed
dates.YearLocator doesn't handle inverted axes
All other Locators are derived from RRuleLocator, which has the following check inside its `__call__` routine: try: dmin, dmax = self.viewlim_to_dt() except ValueError: return [] if dmin > dmax: dmax, dmin = dmin, dmax YearLocator just gets values for `dmin` and `dmax` in the same manner as above and goes on using them without checking for ordering and swapping if necessary. This leads to only one tick on axes using YearLocator.
1 parent 42f09b6 commit 9783e24
Copy full SHA for 9783e24

File tree

Expand file treeCollapse file tree

1 file changed

+6
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-5
lines changed

‎lib/matplotlib/dates.py

Copy file name to clipboardExpand all lines: lib/matplotlib/dates.py
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,10 +698,16 @@ def set_tzinfo(self, tz):
698698

699699
def datalim_to_dt(self):
700700
dmin, dmax = self.axis.get_data_interval()
701+
if dmin > dmax:
702+
dmin, dmax = dmax, dmin
703+
701704
return num2date(dmin, self.tz), num2date(dmax, self.tz)
702705

703706
def viewlim_to_dt(self):
704707
vmin, vmax = self.axis.get_view_interval()
708+
if vmin > vmax:
709+
vmin, vmax = vmax, vmin
710+
705711
return num2date(vmin, self.tz), num2date(vmax, self.tz)
706712

707713
def _get_unit(self):
@@ -748,8 +754,6 @@ def __call__(self):
748754
return self.tick_values(dmin, dmax)
749755

750756
def tick_values(self, vmin, vmax):
751-
if vmin > vmax:
752-
vmax, vmin = vmin, vmax
753757
delta = relativedelta(vmax, vmin)
754758

755759
# We need to cap at the endpoints of valid datetime
@@ -820,9 +824,6 @@ def autoscale(self):
820824
Set the view limits to include the data range.
821825
"""
822826
dmin, dmax = self.datalim_to_dt()
823-
if dmin > dmax:
824-
dmax, dmin = dmin, dmax
825-
826827
delta = relativedelta(dmax, dmin)
827828

828829
# We need to cap at the endpoints of valid datetime

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.