Skip to content

Commit

Permalink
Merge pull request #3648 from elpres/patch-1
Browse files Browse the repository at this point in the history
FIX: dates.YearLocator doesn't handle inverted axes
  • Loading branch information
tacaswell committed Jul 17, 2015
2 parents 786eb8c + 9783e24 commit 8a34d46
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/matplotlib/dates.py
Expand Up @@ -698,10 +698,16 @@ def set_tzinfo(self, tz):

def datalim_to_dt(self):
dmin, dmax = self.axis.get_data_interval()
if dmin > dmax:
dmin, dmax = dmax, dmin

return num2date(dmin, self.tz), num2date(dmax, self.tz)

def viewlim_to_dt(self):
vmin, vmax = self.axis.get_view_interval()
if vmin > vmax:
vmin, vmax = vmax, vmin

return num2date(vmin, self.tz), num2date(vmax, self.tz)

def _get_unit(self):
Expand Down Expand Up @@ -748,8 +754,6 @@ def __call__(self):
return self.tick_values(dmin, dmax)

def tick_values(self, vmin, vmax):
if vmin > vmax:
vmax, vmin = vmin, vmax
delta = relativedelta(vmax, vmin)

# We need to cap at the endpoints of valid datetime
Expand Down Expand Up @@ -820,9 +824,6 @@ def autoscale(self):
Set the view limits to include the data range.
"""
dmin, dmax = self.datalim_to_dt()
if dmin > dmax:
dmax, dmin = dmin, dmax

delta = relativedelta(dmax, dmin)

# We need to cap at the endpoints of valid datetime
Expand Down

0 comments on commit 8a34d46

Please sign in to comment.