@@ -19,12 +19,12 @@ class DateConverter(units.ConversionInterface):
1919
2020 @staticmethod
2121 def convert(value, unit, axis):
22- 'convert value to a scalar or array'
22+ 'Convert a datetime value to a scalar or array'
2323 return dates.date2num(value)
2424
2525 @staticmethod
2626 def axisinfo(unit, axis):
27- 'return major and minor tick locators and formatters'
27+ 'Return major and minor tick locators and formatters'
2828 if unit!='date': return None
2929 majloc = dates.AutoDateLocator()
3030 majfmt = dates.AutoDateFormatter(majloc)
@@ -34,10 +34,10 @@ def axisinfo(unit, axis):
3434
3535 @staticmethod
3636 def default_units(x, axis):
37- 'return the default unit for x or None'
37+ 'Return the default unit for x or None'
3838 return 'date'
3939
40- # Finally we register our object type with a converter
40+ # Finally we register our object type with the Matplotlib units registry.
4141 units.registry[datetime.date] = DateConverter()
4242
4343"""
@@ -53,22 +53,24 @@ def default_units(x, axis):
5353class AxisInfo (object ):
5454 """
5555 Information to support default axis labeling, tick labeling, and
56- default limits.
56+ default limits. An instance of this class must be returned by
57+ :meth:`ConversionInterface.axisinfo`.
5758 """
5859 def __init__ (self , majloc = None , minloc = None ,
5960 majfmt = None , minfmt = None , label = None ,
6061 default_limits = None ):
6162 """
6263 Parameters
6364 ----------
64- majloc, minloc
65- TickLocators for the major and minor ticks.
66- majfmt, minfmt
67- TickFormatters for the major and minor ticks.
68- label
65+ majloc, minloc : Locator, optional
66+ Tick locators for the major and minor ticks.
67+ majfmt, minfmt : Formatter, optional
68+ Tick formatters for the major and minor ticks.
69+ label : str, optional
6970 The default axis label.
70- default_limits
71- The default min, max of the axis if no data is present.
71+ default_limits : optional
72+ The default min and max limits of the axis if no data has
73+ been plotted.
7274
7375 Notes
7476 -----
@@ -85,7 +87,7 @@ def __init__(self, majloc=None, minloc=None,
8587
8688class ConversionInterface (object ):
8789 """
88- The minimal interface for a converter to take custom instances (or
90+ The minimal interface for a converter to take custom data types (or
8991 sequences) and convert them to values Matplotlib can use.
9092 """
9193 @staticmethod
@@ -130,15 +132,16 @@ def is_numlike(x):
130132
131133class Registry (dict ):
132134 """
133- Register types with conversion interface .
135+ A register that maps types to conversion interfaces .
134136 """
135137 def __init__ (self ):
136138 dict .__init__ (self )
137139 self ._cached = {}
138140
139141 def get_converter (self , x ):
140142 """
141- Get the converter interface instance for *x*, or ``None``.
143+ Get the converter for data that has the same type as *x*. If no
144+ converters are registered for *x*, returns ``None``.
142145 """
143146
144147 if not len (self ):
@@ -153,6 +156,7 @@ def get_converter(self, x):
153156 if classx is not None :
154157 converter = self .get (classx )
155158
159+ # If x is an array, look inside the array for data with units
156160 if isinstance (x , np .ndarray ) and x .size :
157161 xravel = x .ravel ()
158162 try :
@@ -174,6 +178,7 @@ def get_converter(self, x):
174178 converter = self .get_converter (next_item )
175179 return converter
176180
181+ # If we haven't found a converter yet, try to get the first element
177182 if converter is None :
178183 try :
179184 thisx = safe_first_element (x )
0 commit comments