|
From: John H. <jd...@gm...> - 2009-09-21 13:29:20
|
On Sun, Sep 20, 2009 at 9:35 PM, John Hunter <jd...@gm...> wrote: > where myInstance is an object of the type you expect to pass in. As > long as you have registered a converter from type(myInstance) -> > ConversionInterface, you can now specify the default limits through > the ConversionInterface.default_limits method:: > > @staticmethod > def default_units(x, axis): > 'return the default unit for x or None for the given axis' > return None This is a typo: I should be referring to the default_limits attribute of AxisInfo. Instead, I pasted in the default_units method of the conversion interface > As an example in matplotlib.dates, we choose an arbitrary interval, > which while arbitrary avoids the 0..1 problem we have been having:: > > class DateConverter(units.ConversionInterface): > """The units are equivalent to the timezone.""" > > @staticmethod > def axisinfo(unit, axis): > 'return the unit AxisInfo' > # make sure that the axis does not start at 0 > > majloc = AutoDateLocator(tz=unit) > majfmt = AutoDateFormatter(majloc, tz=unit) > datemin = datetime.date(2000, 1, 1) > datemax = datetime.date(2010, 1, 1) > > return units.AxisInfo( majloc=majloc, majfmt=majfmt, label='', > default_limits=(datemin, datemax)) This is the correct way to specify default_limits JDH |