-
Notifications
You must be signed in to change notification settings - Fork 232
Closed
Labels
enhancementImproving an existing featureImproving an existing feature
Description
Description of the desired feature
Support passing in 'datetime' like inputs into the 'region' or '-R' argument in plot
.
- The
region
argument doesn't work with numpydatetime64
objects, have to convert to a string usingnp.datetime_as_string
in order to set the map frame bounds.
The decorator
kwargs_to_strings
convert the list[w, e, s, n]
to a string w/e/s/n. We need to convert datetime64 object to string internally, but it's not ideal to do the conversion in the decorator. I don't have a good solution now.
Originally posted by @seisman in #464 (comment)
Minimal working example:
import pandas as pd
import pygmt
fig = pygmt.Figure()
fig.plot(x=["2020-06-30"], y=[1], region=[pd.Timestamp("2020-01-01"), pd.Timestamp("2020-12-31"), 0, 2])
fig.show()
The error message is:
GMTCLibError: Module 'plot' failed with status code 71:
plot [ERROR]: Option -R parsing failure. Correct syntax:
plot [ERROR]: Offending option -R2020-01-01
This workaround does work, but it's cumbersome:
fig = pygmt.Figure()
fig.plot(
x=[pd.Timestamp("2020-06-30")],
y=[1],
region=[
pd.Timestamp("2020-01-01").isoformat(),
pd.Timestamp("2020-12-31").isoformat(),
0,
2,
],
style="a10c",
frame=True,
)
fig.show()
produces:
Are you willing to help implement and maintain this feature? Yes, but where should this code logic go?
Metadata
Metadata
Assignees
Labels
enhancementImproving an existing featureImproving an existing feature