From 9f920dc5c94e2ced1fe9fa95e846a126113389fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 25 Oct 2023 11:50:38 +0200 Subject: [PATCH 1/3] Fix groupby option for vectorized annotations --- holoviews/plotting/bokeh/annotation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/holoviews/plotting/bokeh/annotation.py b/holoviews/plotting/bokeh/annotation.py index 3b6ef80ad9..56aca1f8d1 100644 --- a/holoviews/plotting/bokeh/annotation.py +++ b/holoviews/plotting/bokeh/annotation.py @@ -43,7 +43,8 @@ def _init_glyph(self, plot, mapping, properties): return super()._init_glyph(plot, mapping, properties) def get_data(self, element, ranges, style): - data = {str(k): v for k, v in element.dataset.data.items()} + data = element.columns(element.kdims) + self._get_hover_data(data, element) default = self._element_default[self.invert_axes].kdims mapping = {str(d): str(k) for d, k in zip(default, element.kdims)} return data, mapping, style From 8831dea1027333ee3a6ccd5a6cf8dcd0ede8a38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 25 Oct 2023 12:51:07 +0200 Subject: [PATCH 2/3] Add muted_alpha --- holoviews/plotting/bokeh/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/holoviews/plotting/bokeh/__init__.py b/holoviews/plotting/bokeh/__init__.py index 838bec2c9f..d3667b271d 100644 --- a/holoviews/plotting/bokeh/__init__.py +++ b/holoviews/plotting/bokeh/__init__.py @@ -283,10 +283,10 @@ def colormap_generator(palette): options.HSpan = Options('style', color=Cycle(), alpha=0.5) options.Arrow = Options('style', arrow_size=10) options.Labels = Options('style', text_align='center', text_baseline='middle') -options.HLines = Options('style', color=Cycle(), line_width=3, alpha=1) -options.VLines = Options('style', color=Cycle(), line_width=3, alpha=1) -options.VSpans = Options('style', color=Cycle(), alpha=0.5) -options.HSpans = Options('style', color=Cycle(), alpha=0.5) +options.HLines = Options('style', color=Cycle(), line_width=3, alpha=1, muted_alpha=0.2) +options.VLines = Options('style', color=Cycle(), line_width=3, alpha=1, muted_alpha=0.2) +options.VSpans = Options('style', color=Cycle(), alpha=0.5, muted_alpha=0.2) +options.HSpans = Options('style', color=Cycle(), alpha=0.5, muted_alpha=0.2) options.Labels = Options('style', text_color=Cycle(), text_align='center', text_baseline='middle') # Graphs From 1d746aa9db781282b9300450e37a6e5826138cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 25 Oct 2023 14:10:18 +0200 Subject: [PATCH 3/3] Remove extra data This is no longer send to the frontend because of self._get_hover_data --- .../plotting/bokeh/test_annotationplot.py | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/holoviews/tests/plotting/bokeh/test_annotationplot.py b/holoviews/tests/plotting/bokeh/test_annotationplot.py index 28688f412b..ab955a8131 100644 --- a/holoviews/tests/plotting/bokeh/test_annotationplot.py +++ b/holoviews/tests/plotting/bokeh/test_annotationplot.py @@ -262,9 +262,8 @@ def test_hlines_plot(self): assert plot.handles["y_range"].end == 5.5 source = plot.handles["source"] - assert list(source.data) == ["y", "extra"] + assert list(source.data) == ["y"] assert (source.data["y"] == [0, 1, 2, 5.5]).all() - assert (source.data["extra"] == [-1, -2, -3, -44]).all() def test_hlines_xlabel_ylabel(self): hlines = HLines( @@ -306,9 +305,8 @@ def test_hlines_plot_invert_axes(self): assert plot.handles["y_range"].end == 1 source = plot.handles["source"] - assert list(source.data) == ["y", "extra"] + assert list(source.data) == ["y"] assert (source.data["y"] == [0, 1, 2, 5.5]).all() - assert (source.data["extra"] == [-1, -2, -3, -44]).all() def test_hlines_nondefault_kdim(self): hlines = HLines( @@ -343,9 +341,8 @@ def test_vlines_plot(self): assert plot.handles["y_range"].end == 1 source = plot.handles["source"] - assert list(source.data) == ["x", "extra"] + assert list(source.data) == ["x"] assert (source.data["x"] == [0, 1, 2, 5.5]).all() - assert (source.data["extra"] == [-1, -2, -3, -44]).all() def test_vlines_plot_invert_axes(self): vlines = VLines( @@ -362,9 +359,8 @@ def test_vlines_plot_invert_axes(self): assert plot.handles["y_range"].end == 5.5 source = plot.handles["source"] - assert list(source.data) == ["x", "extra"] + assert list(source.data) == ["x"] assert (source.data["x"] == [0, 1, 2, 5.5]).all() - assert (source.data["extra"] == [-1, -2, -3, -44]).all() def test_vlines_nondefault_kdim(self): vlines = VLines( @@ -450,10 +446,9 @@ def test_hspans_plot(self): assert plot.handles["y_range"].end == 6.5 source = plot.handles["source"] - assert list(source.data) == ["y0", "y1", "extra"] + assert list(source.data) == ["y0", "y1"] assert (source.data["y0"] == [0, 3, 5.5]).all() assert (source.data["y1"] == [1, 4, 6.5]).all() - assert (source.data["extra"] == [-1, -2, -3]).all() def test_hspans_plot_xlabel_ylabel(self): hspans = HSpans( @@ -479,10 +474,9 @@ def test_hspans_plot_invert_axes(self): assert plot.handles["y_range"].end == 1 source = plot.handles["source"] - assert list(source.data) == ["y0", "y1", "extra"] + assert list(source.data) == ["y0", "y1"] assert (source.data["y0"] == [0, 3, 5.5]).all() assert (source.data["y1"] == [1, 4, 6.5]).all() - assert (source.data["extra"] == [-1, -2, -3]).all() def test_hspans_nondefault_kdims(self): hspans = HSpans( @@ -518,10 +512,9 @@ def test_vspans_plot(self): assert plot.handles["y_range"].end == 1 source = plot.handles["source"] - assert list(source.data) == ["x0", "x1", "extra"] + assert list(source.data) == ["x0", "x1"] assert (source.data["x0"] == [0, 3, 5.5]).all() assert (source.data["x1"] == [1, 4, 6.5]).all() - assert (source.data["extra"] == [-1, -2, -3]).all() def test_vspans_plot_invert_axes(self): vspans = VSpans( @@ -538,10 +531,9 @@ def test_vspans_plot_invert_axes(self): assert plot.handles["y_range"].end == 6.5 source = plot.handles["source"] - assert list(source.data) == ["x0", "x1", "extra"] + assert list(source.data) == ["x0", "x1"] assert (source.data["x0"] == [0, 3, 5.5]).all() assert (source.data["x1"] == [1, 4, 6.5]).all() - assert (source.data["extra"] == [-1, -2, -3]).all() def test_vspans_nondefault_kdims(self): vspans = VSpans(