Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix categorial regression #5850

Merged
merged 3 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
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
Loading