def get_locator(self, dmin, dmax):
    'Pick the best locator based on a distance.'
    delta = relativedelta(dmax, dmin)
    tdelta = (dmax - dmin)
    if (dmin > dmax):
        delta = (- delta)
        tdelta = (- tdelta)
    numYears = float(delta.years)
    numMonths = ((numYears * MONTHS_PER_YEAR) + delta.months)
    numDays = tdelta.days
    numHours = ((numDays * HOURS_PER_DAY) + delta.hours)
    numMinutes = ((numHours * MIN_PER_HOUR) + delta.minutes)
    numSeconds = np.floor(_total_seconds(tdelta))
    numMicroseconds = np.floor((_total_seconds(tdelta) * 1000000.0))
    nums = [numYears, numMonths, numDays, numHours, numMinutes, numSeconds, numMicroseconds]
    use_rrule_locator = (([True] * 6) + [False])
    byranges = [None, 1, 1, 0, 0, 0, None]
    for (i, (freq, num)) in enumerate(zip(self._freqs, nums)):
        if (num < self.minticks):
            byranges[i] = None
            continue
        for interval in self.intervald[freq]:
            if (num <= (interval * (self.maxticks[freq] - 1))):
                break
        else:
            warnings.warn("AutoDateLocator was unable to pick an appropriate interval for this date range. It may be necessary to add an interval value to the AutoDateLocator's intervald dictionary. Defaulting to {0}.".format(interval))
        self._freq = freq
        if (self._byranges[i] and self.interval_multiples):
            byranges[i] = self._byranges[i][::interval]
            interval = 1
        else:
            byranges[i] = self._byranges[i]
        break
    else:
        raise ValueError('No sensible date limit could be found in the AutoDateLocator.')
    if use_rrule_locator[i]:
        (_, bymonth, bymonthday, byhour, byminute, bysecond, _) = byranges
        rrule = rrulewrapper(self._freq, interval=interval, dtstart=dmin, until=dmax, bymonth=bymonth, bymonthday=bymonthday, byhour=byhour, byminute=byminute, bysecond=bysecond)
        locator = RRuleLocator(rrule, self.tz)
    else:
        locator = MicrosecondLocator(interval, tz=self.tz)
    locator.set_axis(self.axis)
    locator.set_view_interval(*self.axis.get_view_interval())
    locator.set_data_interval(*self.axis.get_data_interval())
    return locator
Pick the best locator based on a distance.
def get_locator(self, dmin, dmax):
    
    delta = relativedelta(dmax, dmin)
    tdelta = (dmax - dmin)
    if (dmin > dmax):
        delta = (- delta)
        tdelta = (- tdelta)
    numYears = float(delta.years)
    numMonths = ((numYears * MONTHS_PER_YEAR) + delta.months)
    numDays = tdelta.days
    numHours = ((numDays * HOURS_PER_DAY) + delta.hours)
    numMinutes = ((numHours * MIN_PER_HOUR) + delta.minutes)
    numSeconds = np.floor(_total_seconds(tdelta))
    numMicroseconds = np.floor((_total_seconds(tdelta) * 1000000.0))
    nums = [numYears, numMonths, numDays, numHours, numMinutes, numSeconds, numMicroseconds]
    use_rrule_locator = (([True] * 6) + [False])
    byranges = [None, 1, 1, 0, 0, 0, None]
    for (i, (freq, num)) in enumerate(zip(self._freqs, nums)):
        if (num < self.minticks):
            byranges[i] = None
            continue
        for interval in self.intervald[freq]:
            if (num <= (interval * (self.maxticks[freq] - 1))):
                break
        else:
            warnings.warn("AutoDateLocator was unable to pick an appropriate interval for this date range. It may be necessary to add an interval value to the AutoDateLocator's intervald dictionary. Defaulting to {0}.".format(interval))
        self._freq = freq
        if (self._byranges[i] and self.interval_multiples):
            byranges[i] = self._byranges[i][::interval]
            interval = 1
        else:
            byranges[i] = self._byranges[i]
        break
    else:
        raise ValueError('No sensible date limit could be found in the AutoDateLocator.')
    if use_rrule_locator[i]:
        (_, bymonth, bymonthday, byhour, byminute, bysecond, _) = byranges
        rrule = rrulewrapper(self._freq, interval=interval, dtstart=dmin, until=dmax, bymonth=bymonth, bymonthday=bymonthday, byhour=byhour, byminute=byminute, bysecond=bysecond)
        locator = RRuleLocator(rrule, self.tz)
    else:
        locator = MicrosecondLocator(interval, tz=self.tz)
    locator.set_axis(self.axis)
    locator.set_view_interval(*self.axis.get_view_interval())
    locator.set_data_interval(*self.axis.get_data_interval())
    return locator