diff --git a/holoviews/plotting/bokeh/element.py b/holoviews/plotting/bokeh/element.py index 28a3d31284..9ef835d5a7 100644 --- a/holoviews/plotting/bokeh/element.py +++ b/holoviews/plotting/bokeh/element.py @@ -1730,9 +1730,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] 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] 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'])