☰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

How to change legend interactively ?

Community Support
wu.tianchen2015
wu.tianchen2015

can not find a way to change Legend easily when using bokeh serve

I have tried something like that

fig = figure(plot_width=700,

plot_height=500,

y_axis_type=“log”,

y_range=(10**-2, 10**3),

x_range=(0,100),

x_axis_label=“Time Series (Day)”,

y_axis_label=“Clicks in logarithmic scale”)

new_legends =

for i,label in enumerate(labels):

new_legends.append((label, fig.legend[0].legends[i][1]))

fig.legend[0].trigger(‘name’,fig.legend[0].legends,new_legends)

it doesn’t work generating the error

TypeError: unhashable type: ‘PropertyValueList’

Is there to change the legend dynamically ?

thanks a lot

⌁   Link to post
Sarah_Bird1
Sarah_Bird1

Hi,

I may be wrong on this, but my understanding is not really.

The legend is only rendered once on plot initialization and while other
things can update it doesn't - I believe we have some open issues about
this.

What you can do is update the entire plot in your callback (which may be
too inefficient depending on your use). That should allow the legend to
change.

The alternative is to build a second mini plot that you use as your
legend but is really just a plot with points/lines/text on it that you
can update interactively - very manual but will work.

Sincerely,

Sarah Bird

···

On 1/30/16 11:44 AM, wu.tianchen2015@gmail.com wrote:

can not find a way to change Legend easily when using bokeh serve

I have tried something like that

fig = figure(plot_width=700,
             plot_height=500,
             y_axis_type="log",
             y_range=(10**-2, 10**3),
             x_range=(0,100),
             x_axis_label="Time Series (Day)",
             y_axis_label="Clicks in logarithmic scale")

new_legends =
for i,label in enumerate(labels):
    new_legends.append((label, fig.legend[0].legends[i][1]))
    fig.legend[0].trigger('name',fig.legend[0].legends,new_legends)

it doesn't work generating the error

    TypeError: unhashable type: 'PropertyValueList'

Is there to change the legend dynamically ?

thanks a lot

--
You received this message because you are subscribed to the Google
Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to bokeh+unsubscribe@continuum.io
<mailto:bokeh+unsubscribe@continuum.io>.
To post to this group, send email to bokeh@continuum.io
<mailto:bokeh@continuum.io>.
To view this discussion on the web visit
https://groups.google.com/a/continuum.io/d/msgid/bokeh/fb9fb124-8f53-44b3-b4a5-001675e75835%40continuum.io
<https://groups.google.com/a/continuum.io/d/msgid/bokeh/fb9fb124-8f53-44b3-b4a5-001675e75835%40continuum.io?utm_medium=email&utm_source=footer&gt;\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post
wu.tianchen2015
wu.tianchen2015

Hi Sarah Bird,

thanks a lot for your reply.

I have searched for hours, but can not find a way to do that.

"What you can do is update the entire plot in your callback (which may be

too inefficient depending on your use)"

could you maybe give a small hint on how can I update the entire plot in callback in the context of using “bokeh serve”

thanks a lot

···

On Sunday, January 31, 2016 at 8:15:51 PM UTC+1, Sarah Bird wrote:

Hi,

I may be wrong on this, but my understanding is not really.

The legend is only rendered once on plot initialization and while other

things can update it doesn’t - I believe we have some open issues about

this.

What you can do is update the entire plot in your callback (which may be

too inefficient depending on your use). That should allow the legend to

change.

The alternative is to build a second mini plot that you use as your

legend but is really just a plot with points/lines/text on it that you

can update interactively - very manual but will work.

Sincerely,

Sarah Bird

On 1/30/16 11:44 AM, wu.tian...@gmail.com wrote:

can not find a way to change Legend easily when using bokeh serve

I have tried something like that

fig = figure(plot_width=700,
plot_height=500,
y_axis_type=“log”,

         y_range=(10**-2, 10**3),
         x_range=(0,100),
         x_axis_label="Time Series (Day)",
         y_axis_label="Clicks in logarithmic scale")

new_legends =

for i,label in enumerate(labels):

new_legends.append((label, fig.legend[0].legends[i][1]))
fig.legend[0].trigger('name',fig.legend[0].legends,new_legends)

it doesn’t work generating the error

TypeError: unhashable type: 'PropertyValueList'

Is there to change the legend dynamically ?

thanks a lot

–
You received this message because you are subscribed to the Google

Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to bokeh+un...@continuum.io

mailto:bokeh+un...@continuum.io.

To post to this group, send email to bo...@continuum.io

mailto:bo...@continuum.io.

To view this discussion on the web visit

https://groups.google.com/a/continuum.io/d/msgid/bokeh/fb9fb124-8f53-44b3-b4a5-001675e75835%40continuum.io

<https://groups.google.com/a/continuum.io/d/msgid/bokeh/fb9fb124-8f53-44b3-b4a5-001675e75835%40continuum.io?utm_medium=email&utm_source=footer>.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

⌁   Link to post
Sarah_Bird1
Sarah_Bird1

I think you just replace the old plot with a new plot (the plot is
attached to the document), I've never done this and don't really have an
example. You can see something similar here:

Maybe Brendan has a better pointer.

···

On 2/1/16 4:07 AM, wu.tianchen2015@gmail.com wrote:

Hi Sarah Bird,

thanks a lot for your reply.

I have searched for hours, but can not find a way to do that.

"What you can do is update the entire plot in your callback (which may be
too inefficient depending on your use)"

could you maybe give a small hint on how can I update the entire plot in
callback in the context of using "bokeh serve"

thanks a lot

On Sunday, January 31, 2016 at 8:15:51 PM UTC+1, Sarah Bird wrote:

    Hi,

    I may be wrong on this, but my understanding is not really.

    The legend is only rendered once on plot initialization and while other
    things can update it doesn't - I believe we have some open issues about
    this.

    What you can do is update the entire plot in your callback (which
    may be
    too inefficient depending on your use). That should allow the legend to
    change.

    The alternative is to build a second mini plot that you use as your
    legend but is really just a plot with points/lines/text on it that you
    can update interactively - very manual but will work.

    Sincerely,

    Sarah Bird

    On 1/30/16 11:44 AM, wu.tian...@gmail.com <javascript:> wrote:
    > can not find a way to change Legend easily when using bokeh serve
    >
    > I have tried something like that
    >
    > fig = figure(plot_width=700,
    > plot_height=500,
    > y_axis_type="log",
    > y_range=(10**-2, 10**3),
    > x_range=(0,100),
    > x_axis_label="Time Series (Day)",
    > y_axis_label="Clicks in logarithmic scale")
    >
    > new_legends =
    > for i,label in enumerate(labels):
    > new_legends.append((label, fig.legend[0].legends[i][1]))
    > fig.legend[0].trigger('name',fig.legend[0].legends,new_legends)
    >
    > it doesn't work generating the error
    >
    > TypeError: unhashable type: 'PropertyValueList'
    >
    > Is there to change the legend dynamically ?
    >
    > thanks a lot
    >
    > --
    > You received this message because you are subscribed to the Google
    > Groups "Bokeh Discussion - Public" group.
    > To unsubscribe from this group and stop receiving emails from it,
    send
    > an email to bokeh+un...@continuum.io <javascript:>
    > <mailto:bokeh+un...@continuum.io <javascript:>>.
    > To post to this group, send email to bo...@continuum.io <javascript:>
    > <mailto:bo...@continuum.io <javascript:>>.
    > To view this discussion on the web visit
    >
    https://groups.google.com/a/continuum.io/d/msgid/bokeh/fb9fb124-8f53-44b3-b4a5-001675e75835%40continuum.io
    <https://groups.google.com/a/continuum.io/d/msgid/bokeh/fb9fb124-8f53-44b3-b4a5-001675e75835%40continuum.io&gt;

    >
    <https://groups.google.com/a/continuum.io/d/msgid/bokeh/fb9fb124-8f53-44b3-b4a5-001675e75835%40continuum.io?utm_medium=email&utm_source=footer
    <https://groups.google.com/a/continuum.io/d/msgid/bokeh/fb9fb124-8f53-44b3-b4a5-001675e75835%40continuum.io?utm_medium=email&utm_source=footer&gt;&gt;\.

    > For more options, visit
    https://groups.google.com/a/continuum.io/d/optout
    <https://groups.google.com/a/continuum.io/d/optout&gt;\.

--
You received this message because you are subscribed to the Google
Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to bokeh+unsubscribe@continuum.io
<mailto:bokeh+unsubscribe@continuum.io>.
To post to this group, send email to bokeh@continuum.io
<mailto:bokeh@continuum.io>.
To view this discussion on the web visit
https://groups.google.com/a/continuum.io/d/msgid/bokeh/4323b1e2-17ad-492f-9c36-5234400db6d6%40continuum.io
<https://groups.google.com/a/continuum.io/d/msgid/bokeh/4323b1e2-17ad-492f-9c36-5234400db6d6%40continuum.io?utm_medium=email&utm_source=footer&gt;\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post
Sarah_Bird1
Sarah_Bird1

I think you just replace the old plot with a new plot (the plot is
attached to the document), I've never done this and don't really have an
example. You can see something similar here:

Maybe Brendan has a better pointer.

···

On 2/1/16 4:07 AM, wu.tianchen2015@gmail.com wrote:

Hi Sarah Bird,

thanks a lot for your reply.

I have searched for hours, but can not find a way to do that.

"What you can do is update the entire plot in your callback (which may be
too inefficient depending on your use)"

could you maybe give a small hint on how can I update the entire plot in
callback in the context of using "bokeh serve"

thanks a lot

On Sunday, January 31, 2016 at 8:15:51 PM UTC+1, Sarah Bird wrote:

    Hi,

    I may be wrong on this, but my understanding is not really.

    The legend is only rendered once on plot initialization and while other
    things can update it doesn't - I believe we have some open issues about
    this.

    What you can do is update the entire plot in your callback (which
    may be
    too inefficient depending on your use). That should allow the legend to
    change.

    The alternative is to build a second mini plot that you use as your
    legend but is really just a plot with points/lines/text on it that you
    can update interactively - very manual but will work.

    Sincerely,

    Sarah Bird

    On 1/30/16 11:44 AM, wu.tian...@gmail.com <javascript:> wrote:
    > can not find a way to change Legend easily when using bokeh serve
    >
    > I have tried something like that
    >
    > fig = figure(plot_width=700,
    > plot_height=500,
    > y_axis_type="log",
    > y_range=(10**-2, 10**3),
    > x_range=(0,100),
    > x_axis_label="Time Series (Day)",
    > y_axis_label="Clicks in logarithmic scale")
    >
    > new_legends =
    > for i,label in enumerate(labels):
    > new_legends.append((label, fig.legend[0].legends[i][1]))
    > fig.legend[0].trigger('name',fig.legend[0].legends,new_legends)
    >
    > it doesn't work generating the error
    >
    > TypeError: unhashable type: 'PropertyValueList'
    >
    > Is there to change the legend dynamically ?
    >
    > thanks a lot
    >
    > --
    > You received this message because you are subscribed to the Google
    > Groups "Bokeh Discussion - Public" group.
    > To unsubscribe from this group and stop receiving emails from it,
    send
    > an email to bokeh+un...@continuum.io <javascript:>
    > <mailto:bokeh+un...@continuum.io <javascript:>>.
    > To post to this group, send email to bo...@continuum.io <javascript:>
    > <mailto:bo...@continuum.io <javascript:>>.
    > To view this discussion on the web visit
    >
    https://groups.google.com/a/continuum.io/d/msgid/bokeh/fb9fb124-8f53-44b3-b4a5-001675e75835%40continuum.io
    <https://groups.google.com/a/continuum.io/d/msgid/bokeh/fb9fb124-8f53-44b3-b4a5-001675e75835%40continuum.io&gt;

    >
    <https://groups.google.com/a/continuum.io/d/msgid/bokeh/fb9fb124-8f53-44b3-b4a5-001675e75835%40continuum.io?utm_medium=email&utm_source=footer
    <https://groups.google.com/a/continuum.io/d/msgid/bokeh/fb9fb124-8f53-44b3-b4a5-001675e75835%40continuum.io?utm_medium=email&utm_source=footer&gt;&gt;\.

    > For more options, visit
    https://groups.google.com/a/continuum.io/d/optout
    <https://groups.google.com/a/continuum.io/d/optout&gt;\.

--
You received this message because you are subscribed to the Google
Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to bokeh+unsubscribe@continuum.io
<mailto:bokeh+unsubscribe@continuum.io>.
To post to this group, send email to bokeh@continuum.io
<mailto:bokeh@continuum.io>.
To view this discussion on the web visit
https://groups.google.com/a/continuum.io/d/msgid/bokeh/4323b1e2-17ad-492f-9c36-5234400db6d6%40continuum.io
<https://groups.google.com/a/continuum.io/d/msgid/bokeh/4323b1e2-17ad-492f-9c36-5234400db6d6%40continuum.io?utm_medium=email&utm_source=footer&gt;\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post

End of archived discussion · Replies are disabled