You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description of expected behavior and the observed behavior
I'm trying to plot multiple lines using holoviews with the bokeh back end showing additional hover information. I've settled on using hv.Contours for my use case***.
To include the hover info, I added it to the vdims parameter. I expected this to result in showing my hover information, but if I specified for example color="black" as well, then the lines would still be black. (I would also expect the lines to be a single color by default for my use case, but I believe the primary use of hv.Contours is contours on an image, which probably should be colored by default, so that's fine.)
In practice, although this sets my hover info as expected, it also sets that vdim as the color of the lines, even if I specify a non-vdim line color (see example below).
(Note: if I color the lines by an additional / different vdim, then the lines get colored as expected, which at least presents a natural hack solution on my end.)
***I did not include it in this minimal example, but I need to support sometimes including line-specific viz kwargs on each line, for example line width, alpha, and / or color, which brought me to using hv.Contours instead of hv.Curve or hv.Path, both of which I tried before settling on hv.Contours. My lines are also composed of a potentially varying number of points (and always >2 points), which ruled out the use of hv.Segments.
Complete, minimal, self-contained example code that reproduces the issue
importholoviewsashvimportnumpyasnpfrombokeh.modelsimportHoverToolhv.extension("bokeh")
# generate some random curvesnum_pts=10rng=np.random.default_rng(0)
x=rng.random(size=num_pts*3).reshape(-1, 3)
y=rng.random(size=num_pts*3).reshape(-1, 3)
# generate some corresponding hover informationhover_info_variable_name="hover_info"hover_info= [f"Unique Hover Info: {i:.2f}"foriinrng.random(size=num_pts)]
data_dicts= [
{"x": i, "y": j, hover_info_variable_name: k} fori, j, kinzip(x, y, hover_info)
]
# custom tooltip for showing hover infotooltips=f"""<div> <b>Custom Hover Info: @{{{hover_info_variable_name}}}</b></div>"""hover_tool=HoverTool(
tooltips=tooltips,
description="My Custom Hover Tool",
)
# desired behavior: black lines with correct hover info# observed behavior: correct hover info, but lines colored by vdimcurves_with_hover_info=hv.Contours(
data_dicts,
kdims=["x", "y"],
vdims=[hover_info_variable_name], # include for hover info, NOT for color
).opts(
show_legend=False,
color="black", # this gets ignoredtools=[hover_tool],
)
# this case meets expected behavior: black lines but no hover info to correctly referencecurves_without_hover_info=hv.Contours(
data_dicts,
kdims=["x", "y"], # skipping vdims here
).opts(
show_legend=False,
color="black", # this gets used nowtools=[hover_tool],
)
fig=curves_with_hover_info.opts(
title="Hover info is correct\nbut colored by vdim"
) +curves_without_hover_info.opts(title="Color correct\nbut '???' hover info")
fig# also ran as a script locally to confirm the issue wasn't from running in a jupyter notebook# hv.save(fig, "./contours_bug.html")
This is because we go down a bad route because of the legacy color_index. Setting color_index to 5 in opts will give the desired behavior but raise a warning.
ALL software version info
Software Version Info
Description of expected behavior and the observed behavior
I'm trying to plot multiple lines using
holoviews
with thebokeh
back end showing additional hover information. I've settled on usinghv.Contours
for my use case***.To include the hover info, I added it to the
vdims
parameter. I expected this to result in showing my hover information, but if I specified for examplecolor="black"
as well, then the lines would still be black. (I would also expect the lines to be a single color by default for my use case, but I believe the primary use ofhv.Contours
is contours on an image, which probably should be colored by default, so that's fine.)In practice, although this sets my hover info as expected, it also sets that vdim as the color of the lines, even if I specify a non-vdim line color (see example below).
(Note: if I color the lines by an additional / different vdim, then the lines get colored as expected, which at least presents a natural hack solution on my end.)
***I did not include it in this minimal example, but I need to support sometimes including line-specific viz kwargs on each line, for example line width, alpha, and / or color, which brought me to using
hv.Contours
instead ofhv.Curve
orhv.Path
, both of which I tried before settling onhv.Contours
. My lines are also composed of a potentially varying number of points (and always >2 points), which ruled out the use ofhv.Segments
.Complete, minimal, self-contained example code that reproduces the issue
Stack traceback and/or browser JavaScript console output
N/A
Screenshots or screencasts of the bug in action
The text was updated successfully, but these errors were encountered: