From 7a58347748c46f4ed0ff3520d775b81c26cd4b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Tue, 8 Aug 2023 14:16:46 +0200 Subject: [PATCH 1/3] Fix categorial regression --- holoviews/plotting/mixins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/holoviews/plotting/mixins.py b/holoviews/plotting/mixins.py index e543088699..78f6f3d34f 100644 --- a/holoviews/plotting/mixins.py +++ b/holoviews/plotting/mixins.py @@ -161,7 +161,7 @@ def get_extents(self, element, ranges, range_type='combined', **kwargs): s1 = max(s1, 0) if util.isfinite(s1) else 0 ranges[vdim]['soft'] = (s0, s1) if range_type not in ('combined', 'data'): - return super().get_extents(element, ranges, range_type) + return super().get_extents(element, ranges, range_type, ydim=element.vdims[0]) # Compute stack heights xdim = element.kdims[0] From f966268fce875cc92a466c5177e2574843f5f3ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 9 Aug 2023 10:38:56 +0200 Subject: [PATCH 2/3] Fix another regression as axis_dims is a tuple --- holoviews/plotting/bokeh/element.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/holoviews/plotting/bokeh/element.py b/holoviews/plotting/bokeh/element.py index 54661f0364..07db6010c0 100644 --- a/holoviews/plotting/bokeh/element.py +++ b/holoviews/plotting/bokeh/element.py @@ -1713,9 +1713,7 @@ def _find_axes(self, plot, element): Looks up the axes and plot ranges given the plot and an element. """ axis_dims = self._get_axis_dims(element)[:2] - if self.invert_axes: - axis_dims[0], axis_dims[1] = axis_dims[::-1] - x, y = axis_dims + x, y = axis_dims[::-1] if self.invert_axes else axis_dims if isinstance(x, Dimension) and x.name in plot.extra_x_ranges: x_range = plot.extra_x_ranges[x.name] xaxes = [xaxis for xaxis in plot.xaxis if xaxis.x_range_name == x.name] From f360ff823ee98c93412022bdf699ef9412483549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 16 Aug 2023 13:24:42 +0200 Subject: [PATCH 3/3] Add unittest --- holoviews/tests/plotting/bokeh/test_barplot.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/holoviews/tests/plotting/bokeh/test_barplot.py b/holoviews/tests/plotting/bokeh/test_barplot.py index 5cdffc66e5..ccb4ec9aa7 100644 --- a/holoviews/tests/plotting/bokeh/test_barplot.py +++ b/holoviews/tests/plotting/bokeh/test_barplot.py @@ -1,10 +1,10 @@ import numpy as np -from holoviews.core.overlay import NdOverlay +from holoviews.core.overlay import NdOverlay, Overlay from holoviews.element import Bars from holoviews.plotting.bokeh.util import property_to_dict -from bokeh.models import CategoricalColorMapper, LinearColorMapper +from bokeh.models import CategoricalColorMapper, LinearColorMapper, LinearAxis from ..utils import ParamLogStream from .test_plot import TestBokehPlot, bokeh_renderer @@ -65,6 +65,15 @@ def test_box_whisker_multi_level_sorted_alphanumerically(self): self.assertEqual(x_range.factors, [ ('1', 'A'), ('1', 'B'), ('3', 'A'), ('3', 'B'), ('10', 'A'), ('10', 'B')]) + def test_bars_multi_level_two_factors_in_overlay(self): + # See: https://github.com/holoviz/holoviews/pull/5850 + box= Bars((["1", "2", "3"]*10, ['A', 'B']*15, np.random.randn(30)), + ['Group', 'Category'], 'Value').aggregate(function=np.mean) + overlay = Overlay([box]) + plot = bokeh_renderer.get_plot(overlay) + left_axis = plot.handles["plot"].left[0] + assert isinstance(left_axis, LinearAxis) + def test_bars_positive_negative_mixed(self): bars = Bars([('A', 0, 1), ('A', 1, -1), ('B', 0, 2)], kdims=['Index', 'Category'], vdims=['Value'])