issues: 1317502063
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1317502063 | I_kwDOAMm_X85Oh3xv | 6826 | Success of DataArray.plot() depends on object's history. | 4753005 | closed | 0 | 1 | 2022-07-25T23:40:07Z | 2022-07-26T22:48:39Z | 2022-07-26T22:48:39Z | NONE | What happened?I have the following 2D DataArray
```
ldda
````
I can select a portion of it like so
I can get what seems like an equivalent array (equal values, matching dtypes, etc.) in the following way:
And yet, while I can successfully plot Trying to do the same with
See below for full traceback and minimal working example. What did you expect to happen?I expected Minimal Complete Verifiable Example```Python import xarray as xr import numpy as np da = xr.DataArray( data=np.asarray([[1, 2], [3, 4], [5, 6]]), dims=["x", "y"], ) da.sel(x=0).plot() # Succeeds da.to_dataset(dim='x')[0].plot() # Fails ``` MVCE confirmation
Relevant log output```PythonAttributeError Traceback (most recent call last) /Volumes/scratch/neuropixels/t2_shared_projects/discoflow_v2/discoflow/analysis/ANPIX30/discoflow-day2/get_senzai_ic_loadings.ipynb Cell 18 in <cell line: 1>() ----> 1 da2.plot() File /Volumes/scratch/neuropixels/t2_shared_envs/discoflow_v2/lib/python3.8/site-packages/xarray/plot/plot.py:866, in _PlotMethods.call(self, kwargs) 865 def call(self, kwargs): --> 866 return plot(self._da, **kwargs) File /Volumes/scratch/neuropixels/t2_shared_envs/discoflow_v2/lib/python3.8/site-packages/xarray/plot/plot.py:332, in plot(darray, row, col, col_wrap, ax, hue, rtol, subplot_kws, kwargs) 328 plotfunc = hist 330 kwargs["ax"] = ax --> 332 return plotfunc(darray, kwargs) File /Volumes/scratch/neuropixels/t2_shared_envs/discoflow_v2/lib/python3.8/site-packages/xarray/plot/plot.py:436, in line(darray, row, col, figsize, aspect, size, ax, hue, x, y, xincrease, yincrease, xscale, yscale, xticks, yticks, xlim, ylim, add_legend, _labels, args, kwargs) 432 xplt_val, yplt_val, x_suffix, y_suffix, kwargs = _resolve_intervals_1dplot( 433 xplt.to_numpy(), yplt.to_numpy(), kwargs 434 ) 435 xlabel = label_from_attrs(xplt, extra=x_suffix) --> 436 ylabel = label_from_attrs(yplt, extra=y_suffix) 438 _ensure_plottable(xplt_val, yplt_val) 440 primitive = ax.plot(xplt_val, yplt_val, args, **kwargs) File /Volumes/scratch/neuropixels/t2_shared_envs/discoflow_v2/lib/python3.8/site-packages/xarray/plot/utils.py:491, in label_from_attrs(da, extra) 488 units = _get_units_from_attrs(da) ... 493 textwrap.wrap(name + extra + units, 60, break_long_words=False) 494 ) 495 else: AttributeError: 'int' object has no attribute 'startswith' ``` Anything else we need to know?Thank you for one of my favorite packages! Environment
INSTALLED VERSIONS
------------------
commit: None
python: 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:18)
[GCC 10.3.0]
python-bits: 64
OS: Linux
OS-release: 5.4.0-122-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.12.2
libnetcdf: None
xarray: 2022.3.0
pandas: 1.4.3
numpy: 1.21.0
scipy: 1.8.1
netCDF4: None
pydap: None
h5netcdf: None
h5py: 3.7.0
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2022.7.0
distributed: None
matplotlib: 3.5.1
cartopy: None
seaborn: 0.11.2
numbagg: None
fsspec: 2022.5.0
cupy: None
pint: None
sparse: None
setuptools: 63.2.0
pip: 22.2
conda: None
pytest: 7.1.2
IPython: 8.4.0
sphinx: None
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/6826/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |