Using hover callback in one plot to draw a line in a second plot?

Hi, I would appreciate it if someone could give me an example of the following:

If I have two plots and the first plot has a hover tool, what would the callback need to look like to draw a line in a second plot as I hover over the first plot? I see from the examples in the docs that it’s possible to change the range of a linked plot based on a callback, but I wasn’t sure how to draw a new object using a callback.

Thanks!

Without having more details, the way I’d probably go
about it is to have all the lines ready in the second plot,
but with the alpha set to 0 (making them
invisible) then in
your callback set the line_alpha of the appropriate line
to 1.

                        If this is a

few lines, then just do it manually, something like

line_1 = p.line(…)

                                                                      line_2 =

p.line(…)

                                    callback =

CustomJS(args=dic t(line_1=line_1,
line_2=line_2), code="""

// Reset the alphas

                                            line_1.line_al                                                pha

= 0;

                                                  line_2.line_alpha = 0;

                                                  // Some logic to pick a line you wnat to highlight (line_1 or line_2)

                                                         line_x.line_alpha = 1;

                                        """)

                          If you have lots of

lines then n ote that line_alpha can
be “powered” by
a column. But
for this you’d need to use multiline (which means your line data
is arranged in rows not
columns - so each row is a line).

So you can have a colum n in your data
source called line_alpha and then you
can do p.multi_line( xs=‘xs’,
ys=‘ys’, line_alpha=‘line_alpha’, source=line_source )
and then in your callback you
can update the data to change
the alpha for the line you care
about. (See
the docs for more info on
multiline and updating data
in js callbacks)

···

On 5/5/16 4:53 PM, wrote:

[email protected]

    Hi, I would appreciate it if someone could give me

an example of the following:

      If I have two plots and the first plot has a hover tool,

what would the callback need to look like to draw a line in a
second plot as I hover over the first plot? I see from the
examples in the docs that it’s possible to change the range of
a linked plot based on a callback, but I wasn’t sure how to
draw a new object using a callback.

Thanks!

  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 [email protected].

  To post to this group, send email to [email protected]

  To view this discussion on the web visit [](https://groups.google.com/a/continuum.io/d/msgid/bokeh/0a593395-dcd8-4b34-8a2c-58b262a1b1dd%40continuum.io?utm_medium=email&utm_source=footer)      .

For more options, visit .


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

https://groups.google.com/a/continuum.io/d/msgid/bokeh/0a593395-dcd8-4b34-8a2c-58b262a1b1dd%40continuum.io
https://groups.google.com/a/continuum.io/d/optout