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

plot.line breaks depending on coordinate shape #3933

Closed
apatlpo opened this issue Apr 4, 2020 · 2 comments · Fixed by #3934
Closed

plot.line breaks depending on coordinate shape #3933

apatlpo opened this issue Apr 4, 2020 · 2 comments · Fixed by #3934

Comments

@apatlpo
Copy link
Contributor

apatlpo commented Apr 4, 2020

plot.line breaks depending on coordinate shape, see the code below:

x = np.arange(10)
y = np.arange(20)

ds = xr.Dataset(coords={'x': x, 'y': y})
#ds = ds.assign_coords(z=ds.y+ds.x) # goes through
ds = ds.assign_coords(z=ds.x+ds.y) # breaks
ds['v'] = (ds.x+ds.y)
ds['v'].plot.line(y='z', hue='x')

This breaks with the following error:

...
~/.miniconda3/envs/equinox/lib/python3.7/site-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs)
    340 
    341         if x.shape[0] != y.shape[0]:
--> 342             raise ValueError(f"x and y must have same first dimension, but "
    343                              f"have shapes {x.shape} and {y.shape}")
    344         if x.ndim > 2 or y.ndim > 2:

ValueError: x and y must have same first dimension, but have shapes (20, 10) and (10, 20)

I would have expected that that dimension order would not matter

Versions

Output of `xr.show_versions()`

INSTALLED VERSIONS

commit: None
python: 3.7.6 | packaged by conda-forge | (default, Mar 23 2020, 23:03:20)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 3.12.53-60.30-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.7.4

xarray: 0.15.1
pandas: 1.0.3
numpy: 1.18.1
scipy: 1.4.1
netCDF4: 1.5.3
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: 2.4.0
cftime: 1.1.1.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2.13.0
distributed: 2.13.0
matplotlib: 3.2.1
cartopy: 0.17.0
seaborn: 0.10.0
numbagg: None
setuptools: 46.1.3.post20200325
pip: 20.0.2
conda: None
pytest: None
IPython: 7.13.0
sphinx: None

@TomNicholas
Copy link
Contributor

Thanks for the clear bug report @apatlpo ! I've opened a fix in #3934.

@apatlpo
Copy link
Contributor Author

apatlpo commented Apr 4, 2020

thanks to you for the fix @TomNicholas !

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

Successfully merging a pull request may close this issue.

2 participants