☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Manual Label Bokeh -> hide click removes everything

Community Supportbokeh
Zana
Zana

Hi,

How come in the code below if I want to hide just one of the labels, it takes all of them out. Is it possible to let it know how to seperate them and only hide the one the user clicks on?


from bokeh.models import Legend, LegendItem
from bokeh.plotting import figure, show

p = figure()
r = p.multi_line([[1,2,3], [1,2,3]], [[1,3,2], [3,4,3]],
                 color=["orange", "red"], line_width=4)

legend = Legend(items=[
    LegendItem(label="orange", renderers=[r], index=0),
    LegendItem(label="red", renderers=[r], index=1),
])
p.add_layout(legend)
p.legend.click_policy="hide"
show(p)

⌁   Link to post
p-himik
p-himik

I assume by “hide one of the labels” you mean “hide one of the lines”.
The legend click policy operates at the renderer level, namely the "hide" policy just makes your mouse clicks toggle the renderer.visible property.

You have to use multiple renderers if you want to hide them independently.

⌁   Link to post

End of archived discussion · Replies are disabled