MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / ConciseDateFormatter

Class ConciseDateFormatter

lib/matplotlib/dates.py:595–821  ·  view source on GitHub ↗

A `.Formatter` which attempts to figure out the best format to use for the date, and to make it as compact as possible, but still be complete. This is most useful when used with the `AutoDateLocator`:: >>> locator = AutoDateLocator() >>> formatter = ConciseDateFormatter(locator

Source from the content-addressed store, hash-verified

593
594
595class ConciseDateFormatter(ticker.Formatter):
596 """
597 A `.Formatter` which attempts to figure out the best format to use for the
598 date, and to make it as compact as possible, but still be complete. This is
599 most useful when used with the `AutoDateLocator`::
600
601 >>> locator = AutoDateLocator()
602 >>> formatter = ConciseDateFormatter(locator)
603
604 Parameters
605 ----------
606 locator : `.ticker.Locator`
607 Locator that this axis is using.
608
609 tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
610 Ticks timezone, passed to `.dates.num2date`.
611
612 formats : list of 6 strings, optional
613 Format strings for 6 levels of tick labelling: mostly years,
614 months, days, hours, minutes, and seconds. Strings use
615 the same format codes as `~datetime.datetime.strftime`. Default is
616 ``['%Y', '%b', '%d', '%H:%M', '%H:%M', '%S.%f']``
617
618 zero_formats : list of 6 strings, optional
619 Format strings for tick labels that are "zeros" for a given tick
620 level. For instance, if most ticks are months, ticks around 1 Jan 2005
621 will be labeled "Dec", "2005", "Feb". The default is
622 ``['', '%Y', '%b', '%b-%d', '%H:%M', '%H:%M']``
623
624 offset_formats : list of 6 strings, optional
625 Format strings for the 6 levels that is applied to the "offset"
626 string found on the right side of an x-axis, or top of a y-axis.
627 Combined with the tick labels this should completely specify the
628 date. The default is::
629
630 ['', '%Y', '%Y-%b', '%Y-%b-%d', '%Y-%b-%d', '%Y-%b-%d %H:%M']
631
632 show_offset : bool, default: True
633 Whether to show the offset or not.
634
635 usetex : bool, default: :rc:`text.usetex`
636 To enable/disable the use of TeX's math mode for rendering the results
637 of the formatter.
638
639 Examples
640 --------
641 See :doc:`/gallery/ticks/date_concise_formatter`
642
643 .. plot::
644
645 import datetime
646 import matplotlib.dates as mdates
647
648 base = datetime.datetime(2005, 2, 1)
649 dates = np.array([base + datetime.timedelta(hours=(2 * i))
650 for i in range(732)])
651 N = len(dates)
652 np.random.seed(19680801)

Callers 2

quick_start.pyFile · 0.90
axisinfoMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…