Skip to content

Commit

Permalink
Fix issue with range lookups in (y)-axis creation (#6274)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Jun 11, 2024
1 parent e08703d commit 308cdd2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def _axis_props(self, plots, subplots, element, ranges, pos, *, dim=None,
elif pos == 1 and dim:
dims = [dim]
v0, v1 = util.max_range([
elrange.get(dim.name, {'combined': (None, None)})['combined']
elrange.get(dim.label, {'combined': (None, None)})['combined']
for elrange in ranges.values()
])
axis_label = str(dim)
Expand Down Expand Up @@ -843,7 +843,7 @@ def _create_extra_axes(self, plots, subplots, element, ranges):
if self._subcoord_overlaid:
if opts.get('subcoordinate_y') is None:
continue
if element.kdims:
if sp.overlay_dims:
ax_name = ', '.join(d.pprint_value(k) for d, k in zip(element.kdims, sp_key))
else:
ax_name = el.label
Expand Down
39 changes: 39 additions & 0 deletions holoviews/tests/plotting/bokeh/test_overlayplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,45 @@ def test_ndoverlay_subcoordinate_y_no_batching(self):
assert plot.batched == False
assert len(plot.subplots) == 10

def test_ndoverlay_subcoordinate_y_ranges(self):
data = {
'x': np.arange(10),
'A': np.arange(10),
'B': np.arange(10)*2,
'C': np.arange(10)*3
}
overlay = NdOverlay({
'A': Curve(data, 'x', ('A', 'y')).opts(subcoordinate_y=True),
'B': Curve(data, 'x', ('B', 'y')).opts(subcoordinate_y=True),
'C': Curve(data, 'x', ('C', 'y')).opts(subcoordinate_y=True),
})
plot = bokeh_renderer.get_plot(overlay)

assert plot.state.y_range.start == -0.5
assert plot.state.y_range.end == 2.5
for sp in plot.subplots.values():
assert sp.handles['y_range'].start == 0
assert sp.handles['y_range'].end == 27

def test_overlay_subcoordinate_y_ranges(self):
data = {
'x': np.arange(10),
'A': np.arange(10),
'B': np.arange(10)*2,
'C': np.arange(10)*3
}
overlay = Overlay([
Curve(data, 'x', ('A', 'y'), label='A').opts(subcoordinate_y=True),
Curve(data, 'x', ('B', 'y'), label='B').opts(subcoordinate_y=True),
Curve(data, 'x', ('C', 'y'), label='C').opts(subcoordinate_y=True),
])
plot = bokeh_renderer.get_plot(overlay)

assert plot.state.y_range.start == -0.5
assert plot.state.y_range.end == 2.5
for sp in plot.subplots.values():
assert sp.handles['y_range'].start == 0
assert sp.handles['y_range'].end == 27


class TestLegends(TestBokehPlot):
Expand Down

0 comments on commit 308cdd2

Please sign in to comment.