home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 453280699

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/pull/2665#issuecomment-453280699 https://api.github.com/repos/pydata/xarray/issues/2665 453280699 MDEyOklzc3VlQ29tbWVudDQ1MzI4MDY5OQ== 14314623 2019-01-10T22:31:48Z 2019-01-10T22:32:16Z CONTRIBUTOR

I have been along the lines of a short example. This works for timeseries data.

``` import xarray as xr import numpy as np %matplotlib inline

Create a simple line dataarray with cftime

time = xr.cftime_range(start='2000', periods=6, freq='2MS', calendar='noleap') data = np.random.rand(len(time)) da = xr.DataArray(data, coords=[('time', time)]) da.plot() ```

For pcolormesh plots this still fails.

```

Create a simple line dataarray with cftime

time = xr.cftime_range(start='2000', periods=6, freq='2MS', calendar='noleap') data2 = np.random.rand(len(time), 4) da2 = xr.DataArray(data2, coords=[('time', time), ('other', range(4))]) da2.plot() ```

--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-2-645c66b57bde> in <module> 3 data2 = np.random.rand(len(time), 4) 4 da2 = xr.DataArray(data2, coords=[('time', time), ('other', range(4))]) ----> 5 da2.plot() ~/Work/CODE/PYTHON/xarray/xarray/plot/plot.py in __call__(self, **kwargs) 585 586 def __call__(self, **kwargs): --> 587 return plot(self._da, **kwargs) 588 589 @functools.wraps(hist) ~/Work/CODE/PYTHON/xarray/xarray/plot/plot.py in plot(darray, row, col, col_wrap, ax, hue, rtol, subplot_kws, **kwargs) 220 kwargs['ax'] = ax 221 --> 222 return plotfunc(darray, **kwargs) 223 224 ~/Work/CODE/PYTHON/xarray/xarray/plot/plot.py in newplotfunc(darray, x, y, figsize, size, aspect, ax, row, col, col_wrap, xincrease, yincrease, add_colorbar, add_labels, vmin, vmax, cmap, center, robust, extend, levels, infer_intervals, colors, subplot_kws, cbar_ax, cbar_kwargs, xscale, yscale, xticks, yticks, xlim, ylim, norm, **kwargs) 887 vmax=cmap_params['vmax'], 888 norm=cmap_params['norm'], --> 889 **kwargs) 890 891 # Label the plot with metadata ~/Work/CODE/PYTHON/xarray/xarray/plot/plot.py in pcolormesh(x, y, z, ax, infer_intervals, **kwargs) 1135 (np.shape(y)[0] == np.shape(z)[0])): 1136 if len(y.shape) == 1: -> 1137 y = _infer_interval_breaks(y, check_monotonic=True) 1138 else: 1139 # we have to infer the intervals on both axes ~/Work/CODE/PYTHON/xarray/xarray/plot/plot.py in _infer_interval_breaks(coord, axis, check_monotonic) 1085 coord = np.asarray(coord) 1086 -> 1087 if check_monotonic and not _is_monotonic(coord, axis=axis): 1088 raise ValueError("The input coordinate is not sorted in increasing " 1089 "order along axis %d. This can lead to unexpected " ~/Work/CODE/PYTHON/xarray/xarray/plot/plot.py in _is_monotonic(coord, axis) 1069 n = coord.shape[axis] 1070 delta_pos = (coord.take(np.arange(1, n), axis=axis) >= -> 1071 coord.take(np.arange(0, n - 1), axis=axis)) 1072 delta_neg = (coord.take(np.arange(1, n), axis=axis) <= 1073 coord.take(np.arange(0, n - 1), axis=axis)) TypeError: '>=' not supported between instances of 'CalendarDateTime' and 'CalendarDateTime'

Perhaps @spencerkclark has an idea how to deal with differencing cftime.datetime objects?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  398041758
Powered by Datasette · Queries took 0.659ms · About: xarray-datasette