From f4c125dca7f20eb964f26860c665b3b533f8bea8 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sun, 28 Feb 2021 07:12:03 -0800 Subject: [PATCH 1/2] DOC: better intro for dates.py --- lib/matplotlib/dates.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index 8d226c0d73c9..4de93a88c477 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -2,6 +2,26 @@ Matplotlib provides sophisticated date plotting capabilities, standing on the shoulders of python :mod:`datetime` and the add-on module :mod:`dateutil`. +By default, Matpltolib uses the units machinery described in +`~.matplotlib.units` to convert `datetime.datetime`, and `numpy.datetime64` +objects when plotted on an x- or y-axis. The user does not +need to do anything for dates to be formatted, but dates often have strict +formatting needs, so this module provides many axis locators and formatters. +A basic example using `numpy.datetime64` is:: + + import numpy as np + fig, ax = plt.subplots() + times = np.arange(np.datetime64('2001-01-02'), + np.datetime64('2002-02-03'), np.timedelta64(75, 'm')) + y = np.random.randn(len(times)) + ax.plot(times, y) + +.. seealso:: + + - :doc:`/gallery/text_labels_and_annotations/date` + - :doc:`/gallery/ticks_and_spines/date_concise_formatter` + - :doc:`/gallery/ticks_and_spines/date_demo_convert` + .. _date-format: Matplotlib date format From d16b1dd58257225b00152f04f434b8128816d761 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Tue, 2 Mar 2021 17:20:14 -0800 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Elliott Sales de Andrade --- lib/matplotlib/dates.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index 4de93a88c477..29cba779e54a 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -2,18 +2,20 @@ Matplotlib provides sophisticated date plotting capabilities, standing on the shoulders of python :mod:`datetime` and the add-on module :mod:`dateutil`. -By default, Matpltolib uses the units machinery described in -`~.matplotlib.units` to convert `datetime.datetime`, and `numpy.datetime64` +By default, Matplotlib uses the units machinery described in +`~matplotlib.units` to convert `datetime.datetime`, and `numpy.datetime64` objects when plotted on an x- or y-axis. The user does not need to do anything for dates to be formatted, but dates often have strict formatting needs, so this module provides many axis locators and formatters. A basic example using `numpy.datetime64` is:: import numpy as np - fig, ax = plt.subplots() + times = np.arange(np.datetime64('2001-01-02'), np.datetime64('2002-02-03'), np.timedelta64(75, 'm')) y = np.random.randn(len(times)) + + fig, ax = plt.subplots() ax.plot(times, y) .. seealso::