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 groupby option for vectorized annotations #5956

Merged
merged 3 commits into from
Nov 2, 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
8 changes: 4 additions & 4 deletions holoviews/plotting/bokeh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion holoviews/plotting/bokeh/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 8 additions & 16 deletions holoviews/tests/plotting/bokeh/test_annotationplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down