Skip to content

Commit

Permalink
Add support for rendering H/V Line and Span on multi_y (#6376)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Sep 18, 2024
1 parent 9d7fadb commit 88996ed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions holoviews/plotting/bokeh/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ def __init__(self, element, **kwargs):
raise ImportError(msg)
super().__init__(element, **kwargs)

def _get_axis_dims(self, element):
if isinstance(element, (HLines, HSpans)):
return None, element.kdims[0], None
return element.kdims[0], None, None

def _init_glyph(self, plot, mapping, properties):
self._plot_methods = {"single": self._methods[self.invert_axes]}
return super()._init_glyph(plot, mapping, properties)
Expand Down
15 changes: 15 additions & 0 deletions holoviews/tests/plotting/bokeh/test_annotationplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,21 @@ def test_hlines_plot(self):
assert list(source.data) == ["y"]
assert (source.data["y"] == [0, 1, 2, 5.5]).all()

def test_hlines_plot_multi_y(self):
hlines = (
HLines({"y1": [1, 2, 3]}, 'y1') * HLines({'y2': [3, 4, 5]}, 'y2')
).opts(multi_y=True)
plot = bokeh_renderer.get_plot(hlines)
sp1, sp2 = plot.subplots.values()
y1_range = sp1.handles['y_range']
assert y1_range.name == 'y1'
assert y1_range.start == 1
assert y1_range.end == 3
y2_range = sp2.handles['y_range']
assert y2_range.name == 'y2'
assert y2_range.start == 3
assert y2_range.end == 5

def test_hlines_xlabel_ylabel(self):
hlines = HLines(
{"y": [0, 1, 2, 5.5], "extra": [-1, -2, -3, -44]}, vdims=["extra"]
Expand Down

0 comments on commit 88996ed

Please sign in to comment.