Logo Search packages:      
Sourcecode: matplotlib version File versions  Download package


import matplotlib
matplotlib.rcParams['units'] = True
from matplotlib.cbook import iterable, is_numlike
import matplotlib.units as units
import matplotlib.dates as dates
import matplotlib.ticker as ticker
import datetime

00009 class DateConverter(units.ConversionInterface):

    def axisinfo(unit, axis):
        'return the unit AxisInfo'
        if unit=='date':
            majloc = dates.AutoDateLocator()
            majfmt = dates.AutoDateFormatter(majloc)
            return units.AxisInfo(
                majloc = majloc,
                majfmt = majfmt,
        else: return None

    def convert(value, unit, axis):
        if units.ConversionInterface.is_numlike(value): return value
        return dates.date2num(value)

    def default_units(x, axis):
        'return the default unit for x or None'
        return 'date'

units.registry[datetime.date] = DateConverter()
units.registry[datetime.datetime] = DateConverter()

Generated by  Doxygen 1.6.0   Back to index