127127 and to make the format as compact as possible while still having complete
128128 date information. This is most useful when used with the `AutoDateLocator`.
129129
130- * `DateFormatter`: use `strftime` format strings.
130+ * `DateFormatter`: use `~datetime.datetime. strftime` format strings.
131131
132132* `IndexDateFormatter`: date plots with implicit *x* indexing.
133133"""
@@ -585,7 +585,8 @@ def drange(dstart, dend, delta):
585585
586586class DateFormatter (ticker .Formatter ):
587587 """
588- Format a tick (in seconds since the epoch) with a `strftime` format string.
588+ Format a tick (in days since the epoch) with a
589+ `~datetime.datetime.strftime` format string.
589590 """
590591
591592 illegal_s = re .compile (r"((^|[^%])(%%)*%s)" )
@@ -595,8 +596,9 @@ def __init__(self, fmt, tz=None):
595596 Parameters
596597 ----------
597598 fmt : str
598- `strftime` format string
599- tz : `tzinfo`
599+ `~datetime.datetime.strftime` format string
600+ tz : `tzinfo`, default: :rc:`timezone`
601+ Ticks timezone.
600602 """
601603 if tz is None :
602604 tz = _get_rc_timezone ()
@@ -616,14 +618,12 @@ def set_tzinfo(self, tz):
616618
617619
618620class IndexDateFormatter (ticker .Formatter ):
619- """
620- Use with :class:`~matplotlib.ticker.IndexLocator` to cycle format
621- strings by index.
622- """
621+ """Use with `.IndexLocator` to cycle format strings by index."""
622+
623623 def __init__ (self , t , fmt , tz = None ):
624624 """
625625 *t* is a sequence of dates (floating point days). *fmt* is a
626- :func:` strftime` format string.
626+ `~datetime.datetime. strftime` format string.
627627 """
628628 if tz is None :
629629 tz = _get_rc_timezone ()
@@ -643,8 +643,7 @@ class ConciseDateFormatter(ticker.Formatter):
643643 """
644644 This class attempts to figure out the best format to use for the
645645 date, and to make it as compact as possible, but still be complete. This is
646- most useful when used with the :class:`AutoDateLocator`::
647-
646+ most useful when used with the `AutoDateLocator`::
648647
649648 >>> locator = AutoDateLocator()
650649 >>> formatter = ConciseDateFormatter(locator)
@@ -841,7 +840,7 @@ def format_data_short(self, value):
841840class AutoDateFormatter (ticker .Formatter ):
842841 """
843842 This class attempts to figure out the best format to use. This is
844- most useful when used with the :class: `AutoDateLocator`.
843+ most useful when used with the `AutoDateLocator`.
845844
846845 The AutoDateFormatter has a scale dictionary that maps the scale
847846 of the tick (the distance in days between one major tick) and a
@@ -867,10 +866,9 @@ class AutoDateFormatter(ticker.Formatter):
867866 >>> formatter = AutoDateFormatter(locator)
868867 >>> formatter.scaled[1/(24.*60.)] = '%M:%S' # only show min and sec
869868
870- A custom :class:`~matplotlib.ticker.FuncFormatter` can also be used.
871- The following example shows how to use a custom format function to strip
872- trailing zeros from decimal seconds and adds the date to the first
873- ticklabel::
869+ A custom `.FuncFormatter` can also be used. The following example shows
870+ how to use a custom format function to strip trailing zeros from decimal
871+ seconds and adds the date to the first ticklabel::
874872
875873 >>> def my_format_function(x, pos=None):
876874 ... x = matplotlib.dates.num2date(x)
@@ -1240,57 +1238,62 @@ def autoscale(self):
12401238
12411239class AutoDateLocator (DateLocator ):
12421240 """
1243- On autoscale, this class picks the best
1244- :class:`DateLocator` to set the view limits and the tick
1245- locations.
1246- """
1247- def __init__ (self , tz = None , minticks = 5 , maxticks = None ,
1248- interval_multiples = True ):
1249- """
1250- *minticks* is the minimum number of ticks desired, which is used to
1251- select the type of ticking (yearly, monthly, etc.).
1241+ On autoscale, this class picks the best `DateLocator` to set the view
1242+ limits and the tick locations.
12521243
1253- *maxticks* is the maximum number of ticks desired, which controls
1254- any interval between ticks (ticking every other, every 3, etc.).
1255- For really fine-grained control, this can be a dictionary mapping
1256- individual rrule frequency constants (YEARLY, MONTHLY, etc.)
1257- to their own maximum number of ticks. This can be used to keep
1258- the number of ticks appropriate to the format chosen in
1259- :class:`AutoDateFormatter`. Any frequency not specified in this
1260- dictionary is given a default value.
1261-
1262- *tz* is a :class:`tzinfo` instance.
1263-
1264- *interval_multiples* is a boolean that indicates whether ticks
1265- should be chosen to be multiple of the interval. This will lock
1266- ticks to 'nicer' locations. For example, this will force the
1267- ticks to be at hours 0, 6, 12, 18 when hourly ticking is done at
1268- 6 hour intervals.
1269-
1270- The AutoDateLocator has an interval dictionary that maps the
1271- frequency of the tick (a constant from dateutil.rrule) and a
1272- multiple allowed for that ticking. The default looks like this::
1273-
1274- self.intervald = {
1275- YEARLY : [1, 2, 4, 5, 10, 20, 40, 50, 100, 200, 400, 500,
1276- 1000, 2000, 4000, 5000, 10000],
1277- MONTHLY : [1, 2, 3, 4, 6],
1278- DAILY : [1, 2, 3, 7, 14],
1279- HOURLY : [1, 2, 3, 4, 6, 12],
1280- MINUTELY: [1, 5, 10, 15, 30],
1281- SECONDLY: [1, 5, 10, 15, 30],
1282- MICROSECONDLY: [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000,
1283- 5000, 10000, 20000, 50000, 100000, 200000, 500000,
1284- 1000000],
1244+ Attributes
1245+ ----------
1246+ intervald : dict
1247+
1248+ Mapping of tick frequencies (a constant from dateutil.rrule) to
1249+ multiples allowed for that ticking. The default looks like this::
1250+
1251+ self.intervald = {
1252+ YEARLY : [1, 2, 4, 5, 10, 20, 40, 50, 100, 200, 400, 500,
1253+ 1000, 2000, 4000, 5000, 10000],
1254+ MONTHLY : [1, 2, 3, 4, 6],
1255+ DAILY : [1, 2, 3, 7, 14],
1256+ HOURLY : [1, 2, 3, 4, 6, 12],
1257+ MINUTELY: [1, 5, 10, 15, 30],
1258+ SECONDLY: [1, 5, 10, 15, 30],
1259+ MICROSECONDLY: [1, 2, 5, 10, 20, 50, 100, 200, 500,
1260+ 1000, 2000, 5000, 10000, 20000, 50000,
1261+ 100000, 200000, 500000, 1000000],
12851262 }
12861263
12871264 The interval is used to specify multiples that are appropriate for
12881265 the frequency of ticking. For instance, every 7 days is sensible
12891266 for daily ticks, but for minutes/seconds, 15 or 30 make sense.
12901267 You can customize this dictionary by doing::
12911268
1292- locator = AutoDateLocator()
1293- locator.intervald[HOURLY] = [3] # only show every 3 hours
1269+ locator = AutoDateLocator()
1270+ locator.intervald[HOURLY] = [3] # only show every 3 hours
1271+ """
1272+
1273+ def __init__ (self , tz = None , minticks = 5 , maxticks = None ,
1274+ interval_multiples = True ):
1275+ """
1276+ Parameters
1277+ ----------
1278+ tz : `tzinfo`
1279+ Ticks timezone.
1280+ minticks : int
1281+ The minimum number of ticks desired; controls whether ticks occur
1282+ yearly, monthly, etc.
1283+ maxticks : int
1284+ The maximum number of ticks desired; controls the interval between
1285+ ticks (ticking every other, every 3, etc.). For fine-grained
1286+ control, this can be a dictionary mapping individual rrule
1287+ frequency constants (YEARLY, MONTHLY, etc.) to their own maximum
1288+ number of ticks. This can be used to keep the number of ticks
1289+ appropriate to the format chosen in `AutoDateFormatter`. Any
1290+ frequency not specified in this dictionary is given a default
1291+ value.
1292+ interval_multiples : bool, default: True
1293+ Whether ticks should be chosen to be multiple of the interval,
1294+ locking them to 'nicer' locations. For example, this will force
1295+ the ticks to be at hours 0, 6, 12, 18 when hourly ticking is done
1296+ at 6 hour intervals.
12941297 """
12951298 DateLocator .__init__ (self , tz )
12961299 self ._locator = YearLocator (tz = tz )
@@ -1883,17 +1886,16 @@ def weeks(w):
18831886
18841887class DateConverter (units .ConversionInterface ):
18851888 """
1886- Converter for datetime.date and datetime.datetime data,
1887- or for date/time data represented as it would be converted
1888- by :func:`date2num`.
1889+ Converter for `datetime.date` and `datetime.datetime` data, or for
1890+ date/time data represented as it would be converted by `date2num`.
18891891
18901892 The 'unit' tag for such data is None or a tzinfo instance.
18911893 """
18921894
18931895 @staticmethod
18941896 def axisinfo (unit , axis ):
18951897 """
1896- Return the :class: `~matplotlib.units.AxisInfo` for *unit*.
1898+ Return the `~matplotlib.units.AxisInfo` for *unit*.
18971899
18981900 *unit* is a tzinfo instance or None.
18991901 The *axis* argument is required but not used.
@@ -1911,8 +1913,8 @@ def axisinfo(unit, axis):
19111913 @staticmethod
19121914 def convert (value , unit , axis ):
19131915 """
1914- If *value* is not already a number or sequence of numbers,
1915- convert it with :func: `date2num`.
1916+ If *value* is not already a number or sequence of numbers, convert it
1917+ with `date2num`.
19161918
19171919 The *unit* and *axis* arguments are not used.
19181920 """
@@ -1939,13 +1941,7 @@ def default_units(x, axis):
19391941
19401942
19411943class ConciseDateConverter (DateConverter ):
1942- """
1943- Converter for datetime.date and datetime.datetime data,
1944- or for date/time data represented as it would be converted
1945- by :func:`date2num`.
1946-
1947- The 'unit' tag for such data is None or a tzinfo instance.
1948- """
1944+ # docstring inherited
19491945
19501946 def __init__ (self , formats = None , zero_formats = None , offset_formats = None ,
19511947 show_offset = True ):
@@ -1956,22 +1952,15 @@ def __init__(self, formats=None, zero_formats=None, offset_formats=None,
19561952 super ().__init__ ()
19571953
19581954 def axisinfo (self , unit , axis ):
1959- """
1960- Return the :class:`~matplotlib.units.AxisInfo` for *unit*.
1961-
1962- *unit* is a tzinfo instance or None.
1963- The *axis* argument is required but not used.
1964- """
1955+ # docstring inherited
19651956 tz = unit
1966-
19671957 majloc = AutoDateLocator (tz = tz )
19681958 majfmt = ConciseDateFormatter (majloc , tz = tz , formats = self ._formats ,
19691959 zero_formats = self ._zero_formats ,
19701960 offset_formats = self ._offset_formats ,
19711961 show_offset = self ._show_offset )
19721962 datemin = datetime .date (2000 , 1 , 1 )
19731963 datemax = datetime .date (2010 , 1 , 1 )
1974-
19751964 return units .AxisInfo (majloc = majloc , majfmt = majfmt , label = '' ,
19761965 default_limits = (datemin , datemax ))
19771966
0 commit comments