datetime locator doesn't work with cftime
See original GitHub issueCode sample, a copy-pastable example if possible
import proplot as plot
import numpy as np
import xarray as xr
times = xr.cftime_range('1990', '2000', freq='M')
data = xr.DataArray(np.random.rand(len(times)),
dims=['time'],
coords=[times])
f, ax = plot.subplots(aspect=2)
ax.plot(data.time, data)
# ax.format(xlocator='year')
# ax.format(xformatter='concise')
Actual result vs. expected result
The x datetime axis appears by default (with the comments included above), but when using ax.format(xlocator='year')
or any locator, the xticks and labeling completely disappear.
When using any formatter (e.g. xformatter='concise')
it breaks with the following error:
ValueError: Cannot convert -3652 to a date. This often happens if non-datetime values are passed to an axis that expects datetime objects.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
matplotlib.pyplot plot_date function breaks on cftime.datetime ...
Found the answer myself, from version 1.1.0 the num2date function in the cftime package changed its default behaviour to return cftime ...
Read more >Using Python datetime to Work With Dates and Times
Have you ever wondered about working with dates and times in Python? In this tutorial, you'll learn all about the built-in Python datetime...
Read more >Fixing common date annoyances - Matplotlib
To fix the first problem, we can use Figure.autofmt_xdate and to fix the second problem we can use the ax.fmt_xdata attribute which can...
Read more >xarray.CFTimeIndex — xarray 0.10.4 documentation
Custom Index for working with CF calendars and dates. All elements of a CFTimeIndex must be cftime.datetime objects. __init__ ($self, /, *args, **kwargs)¶....
Read more >API — cftime 1.0 documentation
dates: A datetime object or a sequence of datetime objects. The datetime objects should not include a time-zone offset. nctime: A netCDF time...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m reopening this based on our discussion at https://github.com/SciTools/nc-time-axis/issues/41. It looks like
nc-time-axis
is sort of a dead repo. This is on the longer-term list forproplot
developments.After the reorganization, the
cftime
additions should go inticker.py
. This isn’t a priority for me right now, but this is an ideal issue for collaboration if someone else wants to try