Skip to content

Commit

Permalink
Improve the gallery example for datetime inputs (GenericMappingTools#919
Browse files Browse the repository at this point in the history
)

Co-authored-by: Dongdong Tian <[email protected]>
  • Loading branch information
2 people authored and Josh Sixsmith committed Dec 21, 2022
1 parent 386fac2 commit 8d85c3d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions examples/gallery/plot/datetime-inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
- :class:`numpy.datetime64`
- :class:`pandas.DatetimeIndex`
- :class:`xarray.DataArray`: datetimes included in a *xarray.DataArray*
- raw datetime strings in `ISO format <https://en.wikipedia.org/wiki/ISO_8601>`__ (e.g. ``"YYYY-MM-DD"``, ``"YYYY-MM-DDTHH"``, and ``"YYYY-MM-DDTHH:MM:SS"``)
- raw datetime strings in `ISO format <https://en.wikipedia.org/wiki/ISO_8601>`__
(e.g. ``"YYYY-MM-DD"``, ``"YYYY-MM-DDTHH"``, and ``"YYYY-MM-DDTHH:MM:SS"``)
- Python built-in :class:`datetime.datetime` and :class:`datetime.date`
We can pass datetime inputs based on one of the types listed above directly to the ``x`` and ``y`` arguments
of e.g. the :meth:`pygmt.Figure.plot` method:
We can pass datetime inputs based on one of the types listed above directly to
the ``x`` and ``y`` parameters of e.g. the :meth:`pygmt.Figure.plot` method.
The ``region`` argument has to include the :math:`x` and :math:`y` axis limits as *str* in the form
*date_min/date_max/ymin/ymax*.
The ``region`` parameter has to include the :math:`x` and :math:`y` axis limits
in the form [*date_min*, *date_max*, *ymin*, *ymax*]. Here *date_min* and
*date_max* can be directly defined as datetime input.
"""

Expand All @@ -30,7 +32,9 @@
# create a basemap with limits of 2010-01-01 to 2020-06-01 on the x axis and
# 0 to 10 on the y axis
fig.basemap(
projection="X15c/5c", region="2010-01-01/2020-06-01/0/10", frame=["WSen", "af"]
projection="X15c/5c",
region=[datetime.date(2010, 1, 1), datetime.date(2020, 6, 1), 0, 10],
frame=["WSen", "af"],
)

# numpy.datetime64 types
Expand Down

0 comments on commit 8d85c3d

Please sign in to comment.