From 3aca1815fc854d8334d8a010d335b359112e06ec Mon Sep 17 00:00:00 2001 From: Wesley Banfield Date: Mon, 19 Apr 2021 12:41:00 +0200 Subject: [PATCH 1/3] Change how upper limit is taken for color_levels --- holoviews/plotting/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/holoviews/plotting/util.py b/holoviews/plotting/util.py index 6a9c5078b8..db8fe725e3 100644 --- a/holoviews/plotting/util.py +++ b/holoviews/plotting/util.py @@ -706,7 +706,7 @@ def info(provider,names): from colorcet import palette_n, glasbey_hv cet_maps = palette_n.copy() cet_maps['glasbey_hv'] = glasbey_hv # Add special hv-specific map - cmaps += info('colorcet', cet_maps) + cmaps += info('colorcet', cet_maps) cmaps += info('colorcet', [p+'_r' for p in cet_maps]) except: pass @@ -960,7 +960,7 @@ def color_intervals(colors, levels, clip=None, N=255): clmin, clmax = clip lidx = int(round(N*((clmin-cmin)/interval))) uidx = int(round(N*((cmax-clmax)/interval))) - uidx = N-uidx + uidx = len(cmap)-uidx if lidx == uidx: uidx = lidx+1 cmap = cmap[lidx:uidx] From ff4e3030880f1741a9df578428125b4bc18ad236 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Fri, 17 May 2024 13:46:28 +0200 Subject: [PATCH 2/3] Update util.py --- holoviews/plotting/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/holoviews/plotting/util.py b/holoviews/plotting/util.py index db8fe725e3..f70d5b0986 100644 --- a/holoviews/plotting/util.py +++ b/holoviews/plotting/util.py @@ -707,8 +707,8 @@ def info(provider,names): cet_maps = palette_n.copy() cet_maps['glasbey_hv'] = glasbey_hv # Add special hv-specific map cmaps += info('colorcet', cet_maps) - cmaps += info('colorcet', [p+'_r' for p in cet_maps]) - except: + cmaps += info('colorcet', [p+'_r' for p in cet_maps if not p.endswith('_r')]) + except ImportError: pass return sorted(unique_iterator(cmaps)) From 9f9019a12b3195bdf6f658ac694013c509959089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Thu, 30 May 2024 13:56:42 +0200 Subject: [PATCH 3/3] Update tests --- holoviews/plotting/util.py | 3 +-- holoviews/tests/plotting/bokeh/test_pathplot.py | 2 +- holoviews/tests/plotting/test_plotutils.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/holoviews/plotting/util.py b/holoviews/plotting/util.py index 8ceeedb22d..4cb3fc26da 100644 --- a/holoviews/plotting/util.py +++ b/holoviews/plotting/util.py @@ -989,8 +989,7 @@ def color_intervals(colors, levels, clip=None, N=255): if clip is not None: clmin, clmax = clip lidx = int(round(N*((clmin-cmin)/interval))) - uidx = int(round(N*((cmax-clmax)/interval))) - uidx = len(cmap)-uidx + uidx = len(cmap) - int(round(N*((cmax-clmax)/interval))) if lidx == uidx: uidx = lidx+1 cmap = cmap[lidx:uidx] diff --git a/holoviews/tests/plotting/bokeh/test_pathplot.py b/holoviews/tests/plotting/bokeh/test_pathplot.py index a3adc691a9..8185cdcee0 100644 --- a/holoviews/tests/plotting/bokeh/test_pathplot.py +++ b/holoviews/tests/plotting/bokeh/test_pathplot.py @@ -131,7 +131,7 @@ def test_path_continuously_varying_color_op(self): self.assertEqual(source.data['date'], np.array([date]*3)) self.assertEqual(cmapper.low, 994) self.assertEqual(cmapper.high, 999) - self.assertEqual(cmapper.palette, colors[-1:]) + self.assertEqual(np.unique(cmapper.palette), colors[-1:]) def test_path_continuously_varying_alpha_op(self): xs = [1, 2, 3, 4] diff --git a/holoviews/tests/plotting/test_plotutils.py b/holoviews/tests/plotting/test_plotutils.py index 1f402691ad..1651607db8 100644 --- a/holoviews/tests/plotting/test_plotutils.py +++ b/holoviews/tests/plotting/test_plotutils.py @@ -598,7 +598,7 @@ def test_color_intervals_clipped(self): colors = ['#5ebaff', '#00faf4', '#ffffcc', '#ffe775', '#ffc140', '#ff8f20', '#ff6060'] cmap, lims = color_intervals(colors, levels, clip=(10, 90), N=100) self.assertEqual(cmap, ['#5ebaff', '#5ebaff', '#5ebaff', '#00faf4', '#00faf4', - '#00faf4', '#00faf4', '#ffffcc']) + '#00faf4', '#00faf4', '#ffffcc', '#ffffcc']) self.assertEqual(lims, (10, 90))