Skip to content

Commit

Permalink
Fix categorial regression (#5850)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Aug 16, 2023
1 parent dca9c01 commit 2c0eb15
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 1 addition & 3 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
13 changes: 11 additions & 2 deletions holoviews/tests/plotting/bokeh/test_barplot.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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'])
Expand Down

0 comments on commit 2c0eb15

Please sign in to comment.