Skip to content

Commit

Permalink
Change how upper limit is taken for color_levels (#4898)
Browse files Browse the repository at this point in the history
  • Loading branch information
WesleyTheGeolien authored May 30, 2024
1 parent f39e0a0 commit 6a21c19
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions holoviews/plotting/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = N-uidx
uidx = len(cmap) - int(round(N*((cmax-clmax)/interval)))
if lidx == uidx:
uidx = lidx+1
cmap = cmap[lidx:uidx]
Expand Down
2 changes: 1 addition & 1 deletion holoviews/tests/plotting/bokeh/test_pathplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion holoviews/tests/plotting/test_plotutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down

0 comments on commit 6a21c19

Please sign in to comment.