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

_color_palette not using full range of colors if seaborn is installed #1896

Closed
mathause opened this issue Feb 8, 2018 · 2 comments
Closed

Comments

@mathause
Copy link
Collaborator

mathause commented Feb 8, 2018

from xarray.plot.utils import import_seaborn
_color_palette('Greys', 3)

Returns
0.85, ...
0.58, ...
0.31, ...

if seaborn is installed, and

1.00, ...
0.58, ...
0.00, ...

otherwise

Problem description

the return value of _color_palette('Greys', 3) is different when seaborn is installed or not.

The relevant code is here:

colors_i = np.linspace(0, 1., n_colors)

pal = cmap(colors_i)

The same logic in seaborn
https://github.com/mwaskom/seaborn/blob/0beede57152ce80ce1d4ef5d0c0f1cb61d118375/seaborn/palettes.py#L411

Intuitively I prefer the xarray solution because this uses the full range of colors which I find beneficial, however there may be a reason for this I'm not aware of.

Maybe @mwaskom will answer:
mwaskom/seaborn#1372

Expected Output

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.5.4.final.0 python-bits: 64 OS: Linux OS-release: 3.13.0-141-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8

xarray: 0.10.0
pandas: 0.21.0
numpy: 1.13.3
scipy: 1.0.0
netCDF4: 1.3.1
h5netcdf: 0.5.0
Nio: None
bottleneck: 1.2.1
cyordereddict: None
dask: 0.16.0
matplotlib: 2.1.1
cartopy: 0.15.1
seaborn: 0.8.1
setuptools: 38.2.4
pip: 9.0.1
conda: None
pytest: None
IPython: 6.2.1
sphinx: None

~~

edit:

sorry I pressed the button to early

@mathause mathause changed the title _color_palette not use full range of colors if s _color_palette not useing full range of colors if seaborn is installed Feb 8, 2018
@mathause mathause changed the title _color_palette not useing full range of colors if seaborn is installed _color_palette not using full range of colors if seaborn is installed Feb 8, 2018
@shoyer
Copy link
Member

shoyer commented Feb 8, 2018

Using seaborn as a fall-back here was probably a mistake. It's better to give consistent results independently of whether an optional dependency is installed.

@fmaussion
Copy link
Member

See #1902 for a fix

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

No branches or pull requests

3 participants