Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plotting with timedelta64 axis #2898

Open
kcajf opened this issue Apr 16, 2019 · 1 comment
Open

Plotting with timedelta64 axis #2898

kcajf opened this issue Apr 16, 2019 · 1 comment

Comments

@kcajf
Copy link

kcajf commented Apr 16, 2019

Pandas plotting has nice handling of timedelta64 axes - xarray seems to just plot these as integer nanoseconds. Would be great to have this functionality in xarray:

data = xr.DataArray(np.random.random(100), coords=[('td', np.arange(np.timedelta64(0), np.timedelta64(10, 'h'), np.timedelta64(6, 'm')))])

data.plot.line(x='td')

plt.figure()

data.to_pandas().plot()

Screenshot from 2019-04-16 05-17-54

@dcherian
Copy link
Contributor

looks like matplotlib doesn't add nice labels for timedelta64:
plt.plot(data.td.values, data.values) looks like data.plot().

Pandas is doing it's own thing here: https://github.com/pandas-dev/pandas/blob/68b1da7f53f043b21e3f722e8872e19941a10250/pandas/plotting/_converter.py#L1125

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants