I have a bar plot with two static HLine, and would like to add a label to them (or a legend) so that they are defined on the plot. I tried something like:
eq = (
sr2.hvplot(
kind="bar",
groupby ="rl",
dynamic = False,)
* hv.HLine(0.35, name="IA1").opts(color='red')
* hv.HLine(0.2, label="IA2").opts(color='green')
)
but no label comes with the chart.
This answer to a similar question explains that it is not easy, and you need a workaround:
How do I get a full-height vertical line with a legend label in holoviews + bokeh?
You can also use parts of this solution:
https://discourse.holoviz.org/t/horizontal-spikes/117
Maybe the easiest is just to not use
hv.HLine()
when you would like a legend with your horizontal line, but create a manual line yourself withhv.Curve()
instead:Resulting plot: