home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 302679890

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
302679890 MDU6SXNzdWUzMDI2Nzk4OTA= 1966 imshow should work with third dimension of len 1 10050469 closed 0     2 2018-03-06T12:22:57Z 2018-03-08T23:51:45Z 2018-03-08T23:51:45Z MEMBER      

Code Sample, a copy-pastable example if possible

```python import xarray as xr import numpy as np

da = xr.DataArray(np.arange(9).reshape((1, 3, 3)))

da.plot() # works da.plot.imshow() # fails ``` Error log:

``` /home/mowglie/Documents/git/xarray/xarray/plot/utils.py:295: UserWarning: Several dimensions of this array could be colors. Xarray will use the last possible dimension ('dim_2') to match matplotlib.pyplot.imshow. You can pass names of x, y, and/or rgb dimensions to override this guess. 'and/or rgb dimensions to override this guess.' % rgb) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-7-a0592d3e8758> in <module>() ----> 1 da.plot.imshow() ~/Documents/git/xarray/xarray/plot/plot.py in plotmethod(_PlotMethods_obj, x, y, figsize, size, aspect, ax, row, col, col_wrap, xincrease, yincrease, add_colorbar, add_labels, vmin, vmax, cmap, colors, center, robust, extend, levels, infer_intervals, subplot_kws, cbar_ax, cbar_kwargs, **kwargs) 679 for arg in ['_PlotMethods_obj', 'newplotfunc', 'kwargs']: 680 del allargs[arg] --> 681 return newplotfunc(**allargs) 682 683 # Add to class _PlotMethods ~/Documents/git/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, **kwargs) 553 rgb = kwargs.pop('rgb', None) 554 xlab, ylab = _infer_xy_labels( --> 555 darray=darray, x=x, y=y, imshow=imshow_rgb, rgb=rgb) 556 557 if rgb is not None and plotfunc.__name__ != 'imshow': ~/Documents/git/xarray/xarray/plot/utils.py in _infer_xy_labels(darray, x, y, imshow, rgb) 308 assert x is None or x != y 309 if imshow and darray.ndim == 3: --> 310 return _infer_xy_labels_3d(darray, x, y, rgb) 311 312 if x is None and y is None: ~/Documents/git/xarray/xarray/plot/utils.py in _infer_xy_labels_3d(darray, x, y, rgb) 297 298 # Finally, we pick out the red slice and delegate to the 2D version: --> 299 return _infer_xy_labels(darray.isel(**{rgb: 0}).squeeze(), x, y) 300 301 ~/Documents/git/xarray/xarray/plot/utils.py in _infer_xy_labels(darray, x, y, imshow, rgb) 312 if x is None and y is None: 313 if darray.ndim != 2: --> 314 raise ValueError('DataArray must be 2d') 315 y, x = darray.dims 316 elif x is None: ValueError: DataArray must be 2d ```
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1966/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 2 rows from issues_id in issues_labels
  • 2 rows from issue in issue_comments
Powered by Datasette · Queries took 0.491ms · About: xarray-datasette