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: ValueError for invalid hue argument is confusing #4913

Closed
tmieslinger opened this issue Feb 16, 2021 · 2 comments · Fixed by #5060
Closed

plot: ValueError for invalid hue argument is confusing #4913

tmieslinger opened this issue Feb 16, 2021 · 2 comments · Fixed by #5060

Comments

@tmieslinger
Copy link

import xarray as xr
xr.DataArray([[1,2,3], [4,5,6]], dims=("a", "b")).plot(x="a", hue="c")  # note: it should be hue="b"

What happened:
raises

ValueError: y must be one of None, 'a', 'b'

What you expected to happen:

ValueError: hue must be one of None, 'a', 'b'

Environment:

Output of xr.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.7.7 (default, Mar 23 2020, 22:36:06)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 3.16.0-4-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_US.utf-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.6.3

xarray: 0.16.2
pandas: 1.2.1
numpy: 1.19.2
scipy: 1.5.2
netCDF4: 1.5.4
pydap: installed
h5netcdf: None
h5py: 2.10.0
Nio: None
zarr: 2.6.1
cftime: 1.3.1
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.1.0
cfgrib: None
iris: None
bottleneck: None
dask: 2021.01.1
distributed: 2021.01.1
matplotlib: 3.3.2
cartopy: 0.18.0
seaborn: 0.11.1
numbagg: None
pint: 0.16.1
setuptools: 52.0.0.post20210125
pip: 20.3.3
conda: 4.9.2
pytest: 6.2.2
IPython: 7.20.0
sphinx: 3.4.3

@keewis
Copy link
Collaborator

keewis commented Mar 20, 2021

the issue here is that if y is None we pretend y=hue:

xname, huename = _infer_xy_labels(darray=darray, x=x, y=hue)

So we either need to refactor _infer_xy_labels or call _assert_valid_xy(darray, hue, "hue") before the call to _infer_xy_labels.

Edit: I think I would prefer the refactor, but the _assert_valid_xy fix is a single line...

@tmieslinger
Copy link
Author

Cool! Thanks for fixing it :)

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.

3 participants