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 levels not respected #4897

Closed
WesleyTheGeolien opened this issue Apr 19, 2021 · 2 comments · Fixed by #4898
Closed

Color levels not respected #4897

WesleyTheGeolien opened this issue Apr 19, 2021 · 2 comments · Fixed by #4898

Comments

@WesleyTheGeolien
Copy link
Contributor

ALL software version info

holoviews 1.13.5 pypi_0 pypi
Python 3.8.5 (default, Sep 4 2020, 02:22:02) [Clang 10.0.0 ] :: Anaconda, Inc. on darwin

Description of expected behavior and the observed behavior

When passing colour_levels to an image opts color_levels I would expect them to be respected eg. the colormap is broken on the limits that are specified.

As you can see in the example below the color_levels specifies 0 as a limit however the purple step includes values greater than 0. (In the data provided this is off the eastern African coast)

Complete, minimal, self-contained example code that reproduces the issue

data here: https://github.com/CEREGE-CL/netcdf_editor_app/blob/main/data/standard.nc

import xarray as xr
import holoviews as hv
import numpy
hv.extension('bokeh')

ds = xr.open_dataset('data/standard.nc')
var = 'Z'

abs_max = numpy.abs((ds[var].min(), ds[var].max())).max()

delta = 1000
clevels = [-abs_max] + [*numpy.arange(0, abs_max, delta)[::-1] * -1, * numpy.arange(0, abs_max, delta)[1:]] + [abs_max]
print('color_levels: ', clevels)

img = hv.Image(
    ds[var],
    group="Map",
).opts(
    invert_axes=True, tools=['hover'], width=600, aspect=2, colorbar=True, cmap='Category10', clim=(-abs_max, abs_max), color_levels = clevels
)

img

Screenshots or screencasts of the bug in action

Screenshot 2021-04-19 at 10 42 18

@WesleyTheGeolien
Copy link
Contributor Author

So it looks like this function is the culprit:

def color_intervals(colors, levels, clip=None, N=255):

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant