def get_locator(self, dmin, dmax): # get the recommended tick locations from AutoDateLocator, then # go one level more numerous ticks self.old_refresh() major_freq = self._freq tick_locations = self._old_locator.tick_values(dmin, dmax) tick_dt = tick_locations[1] - tick_locations[0] # tick_dt is in terms of days. convert it to major_freq dt = self._freqconverter[major_freq](tick_dt) # Check each possible interval of self._freq minor_interval = 0 minor_interval_index = 0 minor_freq = major_freq for i, interval in enumerate(self.intervald[major_freq]): if dt - .5 > interval: minor_interval = interval minor_interval_index = i else: break if minor_interval == 0: # Then we need to go to the next smaller time interval minor_freq = self.next_freq(major_freq) minor_interval = self.intervald[minor_freq][-3] minor_interval_index = len(self.intervald[minor_freq]) - 3 byranges = [None, 1, 1, 0, 0, 0, None] for i, freq in enumerate(self._freqs): if freq != minor_freq: byranges[i] = None else: break minor_freq_index = self.freq_to_index(minor_freq) byranges[minor_freq_index] = self._byranges[minor_freq_index] if minor_freq != self._freqs[-1]: _, bymonth, bymonthday, byhour, byminute, bysecond, _ = byranges rrule = rrulewrapper(minor_freq, interval=minor_interval, dtstart=dmin, until=dmax, bymonth=bymonth, bymonthday=bymonthday, byhour=byhour, byminute=byminute, bysecond=bysecond) locator = RRuleLocator(rrule, self.tz) else: locator = MicrosecondLocator(minor_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
def get_locator(self, dmin, dmax): "pick the best locator based on a distance" delta = relativedelta(dmax, dmin) numYears = delta.years * 1.0 numMonths = (numYears * 12.0) + delta.months numDays = (numMonths * 31.0) + delta.days numHours = (numDays * 24.0) + delta.hours numMinutes = (numHours * 60.0) + delta.minutes numSeconds = (numMinutes * 60.0) + delta.seconds numticks = 5 # self._freq = YEARLY interval = 1 bymonth = 1 bymonthday = 1 byhour = 0 byminute = 0 bysecond = 0 if numYears >= numticks: self._freq = YEARLY elif numMonths >= numticks: self._freq = MONTHLY bymonth = list(range(1, 13)) if (0 <= numMonths) and (numMonths <= 14): interval = 1 # show every month elif (15 <= numMonths) and (numMonths <= 29): interval = 3 # show every 3 months elif (30 <= numMonths) and (numMonths <= 44): interval = 4 # show every 4 months else: # 45 <= numMonths <= 59 interval = 6 # show every 6 months elif numDays >= numticks: self._freq = DAILY bymonth = None bymonthday = list(range(1, 32)) if (0 <= numDays) and (numDays <= 9): interval = 1 # show every day elif (10 <= numDays) and (numDays <= 19): interval = 2 # show every 2 days elif (20 <= numDays) and (numDays <= 35): interval = 3 # show every 3 days elif (36 <= numDays) and (numDays <= 80): interval = 7 # show every 1 week else: # 100 <= numDays <= ~150 interval = 14 # show every 2 weeks elif numHours >= numticks: self._freq = HOURLY bymonth = None bymonthday = None byhour = list(range(0, 24)) # show every hour if (0 <= numHours) and (numHours <= 14): interval = 1 # show every hour elif (15 <= numHours) and (numHours <= 30): interval = 2 # show every 2 hours elif (30 <= numHours) and (numHours <= 45): interval = 3 # show every 3 hours elif (45 <= numHours) and (numHours <= 68): interval = 4 # show every 4 hours elif (68 <= numHours) and (numHours <= 90): interval = 6 # show every 6 hours else: # 90 <= numHours <= 120 interval = 12 # show every 12 hours elif numMinutes >= numticks: self._freq = MINUTELY bymonth = None bymonthday = None byhour = None byminute = list(range(0, 60)) if numMinutes > (10.0 * numticks): interval = 10 # end if elif numSeconds >= numticks: self._freq = SECONDLY bymonth = None bymonthday = None byhour = None byminute = None bysecond = list(range(0, 60)) if numSeconds > (10.0 * numticks): interval = 10 # end if else: # do what? # microseconds as floats, but floats from what reference point? pass 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) 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
def get_locator(self, dmin, dmax): 'Pick the best locator based on a distance.' delta = relativedelta(dmax, dmin) numYears = (delta.years * 1.0) numMonths = (numYears * 12.0) + delta.months numDays = (numMonths * 31.0) + delta.days numHours = (numDays * 24.0) + delta.hours numMinutes = (numHours * 60.0) + delta.minutes numSeconds = (numMinutes * 60.0) + delta.seconds # numticks = 5 # Difference to original AutoDateLocator: less ticks numticks = self.numticks # self._freq = YEARLY interval = 1 bymonth = 1 bymonthday = 1 byhour = 0 byminute = 0 bysecond = 0 if (numYears >= numticks): self._freq = YEARLY interval = int(numYears // numticks) elif (numMonths >= numticks): self._freq = MONTHLY bymonth = range(1, 13) interval = int(numMonths // numticks) elif (numDays >= numticks): self._freq = DAILY bymonth = None bymonthday = range(1, 32) interval = int(numDays // numticks) elif (numHours >= numticks): self._freq = HOURLY bymonth = None bymonthday = None byhour = range(0, 24) # show every hour interval = int(numHours // numticks) elif (numMinutes >= numticks): self._freq = MINUTELY bymonth = None bymonthday = None byhour = None byminute = range(0, 60) interval = int(numMinutes // numticks) # end if elif (numSeconds >= numticks): self._freq = SECONDLY bymonth = None bymonthday = None byhour = None byminute = None bysecond = range(0, 60) interval = int(numSeconds // numticks) # end if else: # do what? # microseconds as floats, but floats from what reference point? pass 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) 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
def get_locator( self, dmin, dmax ): 'pick the best locator based on a distance' delta = relativedelta( dmax, dmin ) numYears = ( delta.years * 1.0 ) numMonths = ( numYears * 12.0 ) + delta.months numDays = ( numMonths * 31.0 ) + delta.days numHours = ( numDays * 24.0 ) + delta.hours numMinutes = ( numHours * 60.0 ) + delta.minutes numSeconds = ( numMinutes * 60.0 ) + delta.seconds numticks = 5 # self._freq = YEARLY interval = 1 bymonth = 1 bymonthday = 1 byhour = 0 byminute = 0 bysecond = 0 if numYears >= numticks: self._freq = YEARLY elif numMonths >= numticks: self._freq = MONTHLY bymonth = range( 1, 13 ) if ( 0 <= numMonths ) and ( numMonths <= 14 ): interval = 1 # show every month elif ( 15 <= numMonths ) and ( numMonths <= 29 ): interval = 3 # show every 3 months elif ( 30 <= numMonths ) and ( numMonths <= 44 ): interval = 4 # show every 4 months else: # 45 <= numMonths <= 59 interval = 6 # show every 6 months elif numDays >= numticks: self._freq = DAILY bymonth = None bymonthday = range( 1, 32 ) if ( 0 <= numDays ) and ( numDays <= 9 ): interval = 1 # show every day elif ( 10 <= numDays ) and ( numDays <= 19 ): interval = 2 # show every 2 days elif ( 20 <= numDays ) and ( numDays <= 35 ): interval = 3 # show every 3 days elif ( 36 <= numDays ) and ( numDays <= 80 ): interval = 7 # show every 1 week else: # 100 <= numDays <= ~150 interval = 14 # show every 2 weeks elif numHours >= numticks: self._freq = HOURLY bymonth = None bymonthday = None byhour = range( 0, 24 ) # show every hour if ( 0 <= numHours ) and ( numHours <= 14 ): interval = 1 # show every hour elif ( 15 <= numHours ) and ( numHours <= 30 ): interval = 2 # show every 2 hours elif ( 30 <= numHours ) and ( numHours <= 45 ): interval = 3 # show every 3 hours elif ( 45 <= numHours ) and ( numHours <= 68 ): interval = 4 # show every 4 hours elif ( 68 <= numHours ) and ( numHours <= 90 ): interval = 6 # show every 6 hours else: # 90 <= numHours <= 120 interval = 12 # show every 12 hours elif numMinutes >= numticks: self._freq = MINUTELY bymonth = None bymonthday = None byhour = None byminute = range( 0, 60 ) if numMinutes > ( 10.0 * numticks ): interval = 10 # end if elif numSeconds >= numticks: self._freq = SECONDLY bymonth = None bymonthday = None byhour = None byminute = None bysecond = range( 0, 60 ) if numSeconds > ( 10.0 * numticks ): interval = 10 # end if else: # do what? # microseconds as floats, but floats from what reference point? pass 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 ) 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