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"""
@@ -568,7 +568,8 @@ def drange(dstart, dend, delta):
568568
569569class DateFormatter (ticker .Formatter ):
570570 """
571- Format a tick (in seconds since the epoch) with a `strftime` format string.
571+ Format a tick (in days since the epoch) with a
572+ `~datetime.datetime.strftime` format string.
572573 """
573574
574575 illegal_s = re .compile (r"((^|[^%])(%%)*%s)" )
@@ -578,8 +579,9 @@ def __init__(self, fmt, tz=None):
578579 Parameters
579580 ----------
580581 fmt : str
581- `strftime` format string
582- tz : `tzinfo`
582+ `~datetime.datetime.strftime` format string
583+ tz : `tzinfo`, default: :rc:`timezone`
584+ Ticks timezone.
583585 """
584586 if tz is None :
585587 tz = _get_rc_timezone ()
@@ -599,14 +601,12 @@ def set_tzinfo(self, tz):
599601
600602
601603class IndexDateFormatter (ticker .Formatter ):
602- """
603- Use with :class:`~matplotlib.ticker.IndexLocator` to cycle format
604- strings by index.
605- """
604+ """Use with `.IndexLocator` to cycle format strings by index."""
605+
606606 def __init__ (self , t , fmt , tz = None ):
607607 """
608608 *t* is a sequence of dates (floating point days). *fmt* is a
609- :func:` strftime` format string.
609+ `~datetime.datetime. strftime` format string.
610610 """
611611 if tz is None :
612612 tz = _get_rc_timezone ()
@@ -626,8 +626,7 @@ class ConciseDateFormatter(ticker.Formatter):
626626 """
627627 This class attempts to figure out the best format to use for the
628628 date, and to make it as compact as possible, but still be complete. This is
629- most useful when used with the :class:`AutoDateLocator`::
630-
629+ most useful when used with the `AutoDateLocator`::
631630
632631 >>> locator = AutoDateLocator()
633632 >>> formatter = ConciseDateFormatter(locator)
@@ -824,7 +823,7 @@ def format_data_short(self, value):
824823class AutoDateFormatter (ticker .Formatter ):
825824 """
826825 This class attempts to figure out the best format to use. This is
827- most useful when used with the :class: `AutoDateLocator`.
826+ most useful when used with the `AutoDateLocator`.
828827
829828 The AutoDateFormatter has a scale dictionary that maps the scale
830829 of the tick (the distance in days between one major tick) and a
@@ -850,10 +849,9 @@ class AutoDateFormatter(ticker.Formatter):
850849 >>> formatter = AutoDateFormatter(locator)
851850 >>> formatter.scaled[1/(24.*60.)] = '%M:%S' # only show min and sec
852851
853- A custom :class:`~matplotlib.ticker.FuncFormatter` can also be used.
854- The following example shows how to use a custom format function to strip
855- trailing zeros from decimal seconds and adds the date to the first
856- ticklabel::
852+ A custom `.FuncFormatter` can also be used. The following example shows
853+ how to use a custom format function to strip trailing zeros from decimal
854+ seconds and adds the date to the first ticklabel::
857855
858856 >>> def my_format_function(x, pos=None):
859857 ... x = matplotlib.dates.num2date(x)
@@ -1223,57 +1221,62 @@ def autoscale(self):
12231221
12241222class AutoDateLocator (DateLocator ):
12251223 """
1226- On autoscale, this class picks the best
1227- :class:`DateLocator` to set the view limits and the tick
1228- locations.
1229- """
1230- def __init__ (self , tz = None , minticks = 5 , maxticks = None ,
1231- interval_multiples = True ):
1232- """
1233- *minticks* is the minimum number of ticks desired, which is used to
1234- select the type of ticking (yearly, monthly, etc.).
1224+ On autoscale, this class picks the best `DateLocator` to set the view
1225+ limits and the tick locations.
12351226
1236- *maxticks* is the maximum number of ticks desired, which controls
1237- any interval between ticks (ticking every other, every 3, etc.).
1238- For really fine-grained control, this can be a dictionary mapping
1239- individual rrule frequency constants (YEARLY, MONTHLY, etc.)
1240- to their own maximum number of ticks. This can be used to keep
1241- the number of ticks appropriate to the format chosen in
1242- :class:`AutoDateFormatter`. Any frequency not specified in this
1243- dictionary is given a default value.
1244-
1245- *tz* is a :class:`tzinfo` instance.
1246-
1247- *interval_multiples* is a boolean that indicates whether ticks
1248- should be chosen to be multiple of the interval. This will lock
1249- ticks to 'nicer' locations. For example, this will force the
1250- ticks to be at hours 0, 6, 12, 18 when hourly ticking is done at
1251- 6 hour intervals.
1252-
1253- The AutoDateLocator has an interval dictionary that maps the
1254- frequency of the tick (a constant from dateutil.rrule) and a
1255- multiple allowed for that ticking. The default looks like this::
1256-
1257- self.intervald = {
1258- YEARLY : [1, 2, 4, 5, 10, 20, 40, 50, 100, 200, 400, 500,
1259- 1000, 2000, 4000, 5000, 10000],
1260- MONTHLY : [1, 2, 3, 4, 6],
1261- DAILY : [1, 2, 3, 7, 14],
1262- HOURLY : [1, 2, 3, 4, 6, 12],
1263- MINUTELY: [1, 5, 10, 15, 30],
1264- SECONDLY: [1, 5, 10, 15, 30],
1265- MICROSECONDLY: [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000,
1266- 5000, 10000, 20000, 50000, 100000, 200000, 500000,
1267- 1000000],
1227+ Attributes
1228+ ----------
1229+ intervald : dict
1230+
1231+ Mapping of tick frequencies (a constant from dateutil.rrule) to
1232+ multiples allowed for that ticking. The default looks like this::
1233+
1234+ self.intervald = {
1235+ YEARLY : [1, 2, 4, 5, 10, 20, 40, 50, 100, 200, 400, 500,
1236+ 1000, 2000, 4000, 5000, 10000],
1237+ MONTHLY : [1, 2, 3, 4, 6],
1238+ DAILY : [1, 2, 3, 7, 14],
1239+ HOURLY : [1, 2, 3, 4, 6, 12],
1240+ MINUTELY: [1, 5, 10, 15, 30],
1241+ SECONDLY: [1, 5, 10, 15, 30],
1242+ MICROSECONDLY: [1, 2, 5, 10, 20, 50, 100, 200, 500,
1243+ 1000, 2000, 5000, 10000, 20000, 50000,
1244+ 100000, 200000, 500000, 1000000],
12681245 }
12691246
12701247 The interval is used to specify multiples that are appropriate for
12711248 the frequency of ticking. For instance, every 7 days is sensible
12721249 for daily ticks, but for minutes/seconds, 15 or 30 make sense.
12731250 You can customize this dictionary by doing::
12741251
1275- locator = AutoDateLocator()
1276- locator.intervald[HOURLY] = [3] # only show every 3 hours
1252+ locator = AutoDateLocator()
1253+ locator.intervald[HOURLY] = [3] # only show every 3 hours
1254+ """
1255+
1256+ def __init__ (self , tz = None , minticks = 5 , maxticks = None ,
1257+ interval_multiples = True ):
1258+ """
1259+ Parameters
1260+ ----------
1261+ tz : `tzinfo`
1262+ Ticks timezone.
1263+ minticks : int
1264+ The minimum number of ticks desired; controls whether ticks occur
1265+ yearly, monthly, etc.
1266+ maxticks : int
1267+ The maximum number of ticks desired; controls the interval between
1268+ ticks (ticking every other, every 3, etc.). For fine-grained
1269+ control, this can be a dictionary mapping individual rrule
1270+ frequency constants (YEARLY, MONTHLY, etc.) to their own maximum
1271+ number of ticks. This can be used to keep the number of ticks
1272+ appropriate to the format chosen in `AutoDateFormatter`. Any
1273+ frequency not specified in this dictionary is given a default
1274+ value.
1275+ interval_multiples : bool, default: True
1276+ Whether ticks should be chosen to be multiple of the interval,
1277+ locking them to 'nicer' locations. For example, this will force
1278+ the ticks to be at hours 0, 6, 12, 18 when hourly ticking is done
1279+ at 6 hour intervals.
12771280 """
12781281 DateLocator .__init__ (self , tz )
12791282 self ._locator = YearLocator (tz = tz )
@@ -1866,17 +1869,16 @@ def weeks(w):
18661869
18671870class DateConverter (units .ConversionInterface ):
18681871 """
1869- Converter for datetime.date and datetime.datetime data,
1870- or for date/time data represented as it would be converted
1871- by :func:`date2num`.
1872+ Converter for `datetime.date` and `datetime.datetime` data, or for
1873+ date/time data represented as it would be converted by `date2num`.
18721874
18731875 The 'unit' tag for such data is None or a tzinfo instance.
18741876 """
18751877
18761878 @staticmethod
18771879 def axisinfo (unit , axis ):
18781880 """
1879- Return the :class: `~matplotlib.units.AxisInfo` for *unit*.
1881+ Return the `~matplotlib.units.AxisInfo` for *unit*.
18801882
18811883 *unit* is a tzinfo instance or None.
18821884 The *axis* argument is required but not used.
@@ -1894,8 +1896,8 @@ def axisinfo(unit, axis):
18941896 @staticmethod
18951897 def convert (value , unit , axis ):
18961898 """
1897- If *value* is not already a number or sequence of numbers,
1898- convert it with :func: `date2num`.
1899+ If *value* is not already a number or sequence of numbers, convert it
1900+ with `date2num`.
18991901
19001902 The *unit* and *axis* arguments are not used.
19011903 """
@@ -1922,13 +1924,7 @@ def default_units(x, axis):
19221924
19231925
19241926class ConciseDateConverter (DateConverter ):
1925- """
1926- Converter for datetime.date and datetime.datetime data,
1927- or for date/time data represented as it would be converted
1928- by :func:`date2num`.
1929-
1930- The 'unit' tag for such data is None or a tzinfo instance.
1931- """
1927+ # docstring inherited
19321928
19331929 def __init__ (self , formats = None , zero_formats = None , offset_formats = None ,
19341930 show_offset = True ):
@@ -1939,22 +1935,15 @@ def __init__(self, formats=None, zero_formats=None, offset_formats=None,
19391935 super ().__init__ ()
19401936
19411937 def axisinfo (self , unit , axis ):
1942- """
1943- Return the :class:`~matplotlib.units.AxisInfo` for *unit*.
1944-
1945- *unit* is a tzinfo instance or None.
1946- The *axis* argument is required but not used.
1947- """
1938+ # docstring inherited
19481939 tz = unit
1949-
19501940 majloc = AutoDateLocator (tz = tz )
19511941 majfmt = ConciseDateFormatter (majloc , tz = tz , formats = self ._formats ,
19521942 zero_formats = self ._zero_formats ,
19531943 offset_formats = self ._offset_formats ,
19541944 show_offset = self ._show_offset )
19551945 datemin = datetime .date (2000 , 1 , 1 )
19561946 datemax = datetime .date (2010 , 1 , 1 )
1957-
19581947 return units .AxisInfo (majloc = majloc , majfmt = majfmt , label = '' ,
19591948 default_limits = (datemin , datemax ))
19601949
0 commit comments