matplotlib 3.5.1

BackRef

.AutoDateFormatter has a .scale dictionary that maps tick scales (the interval in days between one major tick) to format strings; this dictionary defaults to :

self.scaled = {
    DAYS_PER_YEAR: rcParams['date.autoformat.year'],
    DAYS_PER_MONTH: rcParams['date.autoformat.month'],
    1: rcParams['date.autoformat.day'],
    1 / HOURS_PER_DAY: rcParams['date.autoformat.hour'],
    1 / MINUTES_PER_DAY: rcParams['date.autoformat.minute'],
    1 / SEC_PER_DAY: rcParams['date.autoformat.second'],
    1 / MUSECONDS_PER_DAY: rcParams['date.autoformat.microsecond'],
}

The formatter uses the format string corresponding to the lowest key in the dictionary that is greater or equal to the current scale. Dictionary entries can be customized:

locator = AutoDateLocator()
formatter = AutoDateFormatter(locator)
formatter.scaled[1/(24*60)] = '%M:%S' # only show min and sec

Custom callables can also be used instead of format strings. The following example shows how to use a custom format function to strip trailing zeros from decimal seconds and adds the date to the first ticklabel:

def my_format_function(x, pos=None):
    x = matplotlib.dates.num2date(x)
    if pos == 0:
        fmt = '%D %H:%M:%S.%f'
    else:
        fmt = '%H:%M:%S.%f'
    label = x.strftime(fmt)
    label = label.rstrip("0")
    label = label.rstrip(".")
    return label

formatter.scaled[1/(24*60)] = my_format_function

A .Formatter which attempts to figure out the best format to use. This is most useful when used with the AutoDateLocator .

Examples

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

matplotlib.dates.AutoDateFormatter matplotlib.axes._axes.Axes.plot_date matplotlib.pyplot.plot_date matplotlib.dates.AutoDateLocator.__init__ matplotlib.dates

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /matplotlib/dates.py#862
type: <class 'type'>
Commit: