|
7 | 7 | formatters. See :doc:`/gallery/ticks_and_spines/major_minor_demo` for more
|
8 | 8 | information on controlling major and minor ticks.
|
9 | 9 |
|
10 |
| -All Matplotlib date plotting is done by converting date instances into |
11 |
| -days since 0001-01-01 00:00:00 UTC plus one day (for historical reasons). |
12 |
| -The conversion, tick locating and formatting is done behind the scenes |
13 |
| -so this is most transparent to you. The :mod:`matplotlib.dates` module |
14 |
| -provides the converter functions `.date2num` and `.num2date`, which convert |
15 |
| -`datetime.datetime` and `numpy.datetime64` objects to and from Matplotlib's |
16 |
| -internal representation. |
17 |
| -
|
18 |
| -An alternative way of displaying dates can be seen at |
19 |
| -:doc:`/gallery/ticks_and_spines/date_concise_formatter`. |
| 10 | +Matplotlib date plotting is done by converting date instances into |
| 11 | +days since an epoch (by default 1970-01-01T00:00:00). The |
| 12 | +:mod:`matplotlib.dates` module provides the converter functions `.date2num` |
| 13 | +and `.num2date`, which convert `datetime.datetime` and `numpy.datetime64` |
| 14 | +objects to and from Matplotlib's internal representation. These data |
| 15 | +types are registered with with the unit conversion mechanism described in |
| 16 | +:mod:`matplotlib.units`, so the conversion happens automatically for the user. |
| 17 | +The registration process also sets the default tick ``locator`` and |
| 18 | +``formatter`` for the axis to be `~.matplotlib.dates.AutoDateLocator` and |
| 19 | +`~.matplotlib.dates.AutoDateFormatter`. These can be changed manually with |
| 20 | +`.Axis.set_major_locator` and `.Axis.set_major_formatter`; see for example |
| 21 | +:doc:`/gallery/ticks_and_spines/date_demo_convert`. |
| 22 | +
|
| 23 | +An alternative formatter is the `~.matplotlib.dates.ConciseDateFormatter` |
| 24 | +as described at :doc:`/gallery/ticks_and_spines/date_concise_formatter`, |
| 25 | +which often removes the need to rotate the tick labels. |
20 | 26 | """
|
21 | 27 |
|
22 | 28 | import numpy as np
|
|
0 commit comments