diff --git a/holoviews/plotting/plot.py b/holoviews/plotting/plot.py index e57e9a7637..ab4add2572 100644 --- a/holoviews/plotting/plot.py +++ b/holoviews/plotting/plot.py @@ -705,11 +705,11 @@ def _compute_group_range(cls, group, elements, ranges, framewise, data_range = el.range(el_dim, dimension_range=False) data_ranges[(el, el_dim)] = data_range - if dtype is not None and dtype.kind == 'uif' and robust: + if dtype is not None and dtype.kind in 'uif' and robust: percentile = 2 if isinstance(robust, bool) else robust robust_ranges[(el, el_dim)] = ( dim(el_dim, np.nanpercentile, percentile).apply(el), - dim(el_dim, np.nanpercentile, percentile).apply(el) + dim(el_dim, np.nanpercentile, 100 - percentile).apply(el) ) if (any(isinstance(r, str) for r in data_range) or diff --git a/holoviews/tests/plotting/bokeh/test_elementplot.py b/holoviews/tests/plotting/bokeh/test_elementplot.py index 88a30d30b2..19dbfaf215 100644 --- a/holoviews/tests/plotting/bokeh/test_elementplot.py +++ b/holoviews/tests/plotting/bokeh/test_elementplot.py @@ -971,3 +971,14 @@ def test_categorical_overlay_dimension_values_skip_factor(self): plot = bokeh_renderer.get_plot((curve*scatter).redim.values(x=['A', 'C'])) x_range = plot.handles['x_range'] self.assertEqual(x_range.factors, ['A', 'C']) + + def test_clim_percentile(self): + arr = np.random.rand(10,10) + arr[0, 0] = -100 + arr[-1, -1] = 100 + im = Image(arr).opts(clim_percentile=True) + + plot = bokeh_renderer.get_plot(im) + low, high = plot.ranges[('Image',)]['z']['robust'] + assert low > 0 + assert high < 1