How to get dataframe column names to be used for hover tool?

Hello,

I would like to be able to identify individual chart series with the hover tool. I want the column name/series name to show up on the hover tool. I looked at the documentation, but I couldn’t find any that shows how to work with dataframe.

Here’s what I have so far:

https://gist.github.com/anonymous/1eab3bea584bb4145cecbbdb4cea8a38

Thanks in advance!

  • Daniel

Hi,

···

That’s a nice feature, unfortunately we don’t support it right now. Can I suggest u open a github issue.

It is possible to do it though.

I would probably start with p = figure(), make one ColumnDataSource, the do a for loop over your categories, then in each one do :

  1. line = p.line(…) specifying your column

  2. p.add_tools(HoverTool(tooltips=“cat name”, renderers=[line]))

Sorry, for the brevity, I’m on my phone. Hope that makes sense.

Sarah Bird
[email protected]

On Apr 25, 2016, at 8:50 AM, Daniel [email protected] wrote:

Hello,

I would like to be able to identify individual chart series with the hover tool. I want the column name/series name to show up on the hover tool. I looked at the documentation, but I couldn’t find any that shows how to work with dataframe.

Here’s what I have so far:

https://gist.github.com/anonymous/1eab3bea584bb4145cecbbdb4cea8a38

Thanks in advance!

  • Daniel

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/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io.

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

Thanks Sarah. Not sure I’m getting you, but it’s probably because I am not well versed in Bokeh yet. I’ll have to learn it better and get back with you. I was hoping I would just simply pass df.columns to the tooltips somehow. Since bokeh is touted to be tightly integrated with pandas data frames, thought it would be that easy or at least not having to do a looping construct.

···

On Tuesday, April 26, 2016 at 11:45:47 PM UTC-4, Sarah Bird wrote:

Hi,

That’s a nice feature, unfortunately we don’t support it right now. Can I suggest u open a github issue.

It is possible to do it though.

I would probably start with p = figure(), make one ColumnDataSource, the do a for loop over your categories, then in each one do :

  1. line = p.line(…) specifying your column
  1. p.add_tools(HoverTool(tooltips=“cat name”, renderers=[line]))

Sorry, for the brevity, I’m on my phone. Hope that makes sense.

Sarah Bird
[email protected]

On Apr 25, 2016, at 8:50 AM, Daniel [email protected] wrote:

Hello,

I would like to be able to identify individual chart series with the hover tool. I want the column name/series name to show up on the hover tool. I looked at the documentation, but I couldn’t find any that shows how to work with dataframe.

Here’s what I have so far:

https://gist.github.com/anonymous/1eab3bea584bb4145cecbbdb4cea8a38

Thanks in advance!

  • Daniel

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/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io.

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

Hi Daniel,

      T              he

best way to think about it is
that Bokeh is really set-up
to be powered by your columns.

      If you have a column, you can               use it to power many different

aspects of bokeh - the size, pos ition,
color, opacity , … of
your points.

                    Each point/shape is a row.

                                                  So in your hover tooltip, you can

specify @column_name. As each point
is a row then as you hover , the
tooltip will pick off the value
for that row of a particular
column.

                                                                                  Lines

are these funn y
things where the “thin g”
is the whole column.

                                              What

you were hoping to do is completely reasonable, but is not naturally
bokeh-ish if that makes sense.

There is another thing "multi-line" where each row can hold the

points of a line - this could be a solution except that hit-testing
doesn’t work for multi-line and so there’s no hover for multi-line.

Sorry you've stumbled in a funny area. As I said, this is a great request,

and is even hinting at a need for some other kind of api for line-type
things.

Here's the code to do what you need.

`

``data = {``

``    x = [1``,`` 2, 3],``

``   col1 = [2, 4, 5],``

``   col``2 = [4, 6, 7]``

``}``

``source = ColumnDataSource(data)``

``p = figure()``

``for column in ['col1', 'col``2']:``

``    ``line = p.line(x='x', y='col1', source=source)``

``    p.add_``tools(HoverTool(tooltips=``      "This

is %s" % column, renderers=[line]))`

data could just as easily be a DataFrame, I just wrote it like this

for clarity

best,

bird
···

On 4/27/16 7:04 PM, Daniel wrote:

    Thanks Sarah.  Not sure I'm getting you, but it's

probably because I am not well versed in Bokeh yet. I’ll have
to learn it better and get back with you. I was hoping I would
just simply pass df.columns to the tooltips somehow. Since
bokeh is touted to be tightly integrated with pandas data
frames, thought it would be that easy or at least not having to
do a looping construct.

    On Tuesday, April 26, 2016 at 11:45:47 PM UTC-4, Sarah Bird

wrote:

Hi,

          That's a nice feature, unfortunately we don't support

it right now. Can I suggest u open a github issue.

It is possible to do it though.

          I would probably start with p = figure(), make one

ColumnDataSource, the do a for loop over your categories,
then in each one do :

  1. line = p.line(…) specifying your column
  1. p.add_tools(HoverTool( tooltips=“cat name”,
    renderers=[line]))
          Sorry, for the brevity, I'm on my phone. Hope that

makes sense.

          Sarah Bird

[email protected]

          On Apr 25, 2016, at 8:50 AM, Daniel <              >

wrote:

Hello,

                I would like to be able to identify individual

chart series with the hover tool. I want the column
name/series name to show up on the hover tool. I
looked at the documentation, but I couldn’t find any
that shows how to work with dataframe.

Here’s what I have so far:

https://gist.github.com/anonymous/1eab3bea584bb4145cecbbdb4cea8a38

Thanks in advance!

  • Daniel

            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                 .

To view this discussion on the web visit

  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/78f7fff1-4794-4970-a55e-d62c94510627%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)

[email protected]

[email protected]
https://groups.google.com/a/continuum.io/d/msgid/bokeh/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io.

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

          [https://groups.google.com/a/continuum.io/d/msgid/bokeh/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io)

https://groups.google.com/a/continuum.io/d/optout

Thanks Sarah.

I have to admit, I am not familiar with that lower level style API on Bokeh. I guess that this style is considered “plotting with basic gylphs” per this documentation:
http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html

I’ve been studying Bokeh’s high level charts api per this documentation since I like to do with DataFrame data structure instead of having to construct the data with dicts:
http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html

Where examples show I just simply pass in a DataFrame.

From your example, I can only deduce or infer that I have to use a loop to draw each individual line or DataFrame’s column by specifying the corresponding x and y values, is that correct?

For example, I tried:
from bokeh.charts import Line, output_notebook, show
from bokeh.models import HoverTool
from bokeh.plotting import figure, ColumnDataSource
import pandas as pd
import numpy as np)
output_notebook()

df = pd.DataFrame(np.random.rand(10, 5), columns=[‘A’, ‘B’, ‘C’, ‘D’, ‘E’])

source = ColumnDataSource(df)
p = figure(plot_width=400, plot_height=400)
for column in df.columns:
line = p.line(x=df.index, y=‘A’, source=source)
line = p.line(x=df.index, y=‘B’, source=source)
line = p.line(x=df.index, y=‘C’, source=source)
line = p.line(x=df.index, y=‘D’, source=source)
p.add_tools(HoverTool(tooltips=“This is %s” % column, renderers=[line]))

output_notebook()

show(p)

It drew the line charts, but the hover tool only worked for one of the lines.

I also can’t seem to find documentation on what the internals of the ColumnDataSource looks like when I instantiate it or pass it with a DataFrame.

If currently, the only way to do the hover tool containing the column names is by using the lower level style api, then I will probably issue a feature request at the github repo to allow for this using the high level api. I just can’t see myself trying to do all that for column names in the hover tooltip. I don’t think it is worth it for me then. In comparison to plotly, plotly generates the hover tool tips for you using their high level api style using cufflinks which very convenient:
https://plot.ly/ipython-notebooks/cufflinks/

  • Daniel
···

On Thursday, April 28, 2016 at 1:07:35 AM UTC-4, Sarah Bird wrote:

Hi Daniel,

      T              he

best way to think about it is
that Bokeh is really set-up
to be powered by your columns.

      If you have a column, you can               use it to power many different

aspects of bokeh - the size, pos ition,
color, opacity , … of
your points.

                    Each point/shape is a row.



                                                  So in your hover tooltip, you can

specify @column_name. As each point
is a row then as you hover , the
tooltip will pick off the value
for that row of a particular
column.

                                                                                  Lines

are these funn y
things where the “thin g”
is the whole column.

                                              What

you were hoping to do is completely reasonable, but is not naturally
bokeh-ish if that makes sense.

There is another thing "multi-line" where each row can hold the

points of a line - this could be a solution except that hit-testing
doesn’t work for multi-line and so there’s no hover for multi-line.

Sorry you've stumbled in a funny area. As I said, this is a great request,

and is even hinting at a need for some other kind of api for line-type
things.

Here's the code to do what you need.

`

``data = {``

``    x = [1``,`` 2, 3],``

``   col1 = [2, 4, 5],``

``   col``2 = [4, 6, 7]``

``}``

``source = ColumnDataSource(data)``

``p = figure()``

``for column in ['col1', 'col``2']:``

``    ``line = p.line(x='x', y='col1', source=source)``

``    p.add_``tools(HoverTool(tooltips=``      "This

is %s" % column, renderers=[line]))`

data could just as easily be a DataFrame, I just wrote it like this

for clarity

best,



bird

On 4/27/16 7:04 PM, Daniel wrote:

    Thanks Sarah.  Not sure I'm getting you, but it's

probably because I am not well versed in Bokeh yet. I’ll have
to learn it better and get back with you. I was hoping I would
just simply pass df.columns to the tooltips somehow. Since
bokeh is touted to be tightly integrated with pandas data
frames, thought it would be that easy or at least not having to
do a looping construct.

    On Tuesday, April 26, 2016 at 11:45:47 PM UTC-4, Sarah Bird > > wrote:

Hi,

          That's a nice feature, unfortunately we don't support

it right now. Can I suggest u open a github issue.

It is possible to do it though.

          I would probably start with p = figure(), make one

ColumnDataSource, the do a for loop over your categories,
then in each one do :

  1. line = p.line(…) specifying your column
  1. p.add_tools(HoverTool( tooltips=“cat name”,
    renderers=[line]))
          Sorry, for the brevity, I'm on my phone. Hope that

makes sense.

          Sarah Bird

[email protected]

          On Apr 25, 2016, at 8:50 AM, Daniel <[email protected]              > > > > wrote:

Hello,

                I would like to be able to identify individual

chart series with the hover tool. I want the column
name/series name to show up on the hover tool. I
looked at the documentation, but I couldn’t find any
that shows how to work with dataframe.

Here’s what I have so far:

https://gist.github.com/anonymous/1eab3bea584bb4145cecbbdb4cea8a38

Thanks in advance!

  • Daniel

            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/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/](https://groups.google.com/a/)continuum.io/d/msgid/bokeh/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io.

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

  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/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io).

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


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px">
    ](http://continuum.io)

It’s a bit of a hack and I don’t know if this does it for you: from bokeh.plotting import figure, curdocfrom bokeh.models import HoverTool, T - Pastebin.com
I don’t know pandas well enough to know if it translates. The idea is that the hovertool can display info per point so it needs an array-like object in the DataSource.

Sorry if this does not apply to your problem, or is a known workaround.

Cheers,

Robert

torsdag 28. april 2016 12.15.51 UTC+2 skrev Daniel følgende:

···

Hi Daniel,

      T              he

best way to think about it is
that Bokeh is really set-up
to be powered by your columns.

      If you have a column, you can               use it to power many different

aspects of bokeh - the size, pos ition,
color, opacity , … of
your points.

                    Each point/shape is a row.



                                                  So in your hover tooltip, you can

specify @column_name. As each point
is a row then as you hover , the
tooltip will pick off the value
for that row of a particular
column.

                                                                                  Lines

are these funn y
things where the “thin g”
is the whole column.

                                              What

you were hoping to do is completely reasonable, but is not naturally
bokeh-ish if that makes sense.

There is another thing "multi-line" where each row can hold the

points of a line - this could be a solution except that hit-testing
doesn’t work for multi-line and so there’s no hover for multi-line.

Sorry you've stumbled in a funny area. As I said, this is a great request,

and is even hinting at a need for some other kind of api for line-type
things.

Here's the code to do what you need.

`

``data = {``

``    x = [1``,`` 2, 3],``

``   col1 = [2, 4, 5],``

``   col``2 = [4, 6, 7]``

``}``

``source = ColumnDataSource(data)``

``p = figure()``

``for column in ['col1', 'col``2']:``

``    ``line = p.line(x='x', y='col1', source=source)``

``    p.add_``tools(HoverTool(tooltips=``      "This

is %s" % column, renderers=[line]))`

data could just as easily be a DataFrame, I just wrote it like this

for clarity

best,



bird

On 4/27/16 7:04 PM, Daniel wrote:

    Thanks Sarah.  Not sure I'm getting you, but it's

probably because I am not well versed in Bokeh yet. I’ll have
to learn it better and get back with you. I was hoping I would
just simply pass df.columns to the tooltips somehow. Since
bokeh is touted to be tightly integrated with pandas data
frames, thought it would be that easy or at least not having to
do a looping construct.

    On Tuesday, April 26, 2016 at 11:45:47 PM UTC-4, Sarah Bird > > > wrote:

Hi,

          That's a nice feature, unfortunately we don't support

it right now. Can I suggest u open a github issue.

It is possible to do it though.

          I would probably start with p = figure(), make one

ColumnDataSource, the do a for loop over your categories,
then in each one do :

  1. line = p.line(…) specifying your column
  1. p.add_tools(HoverTool( tooltips=“cat name”,
    renderers=[line]))
          Sorry, for the brevity, I'm on my phone. Hope that

makes sense.

          Sarah Bird

[email protected]

          On Apr 25, 2016, at 8:50 AM, Daniel <[email protected]              > > > > > wrote:

Hello,

                I would like to be able to identify individual

chart series with the hover tool. I want the column
name/series name to show up on the hover tool. I
looked at the documentation, but I couldn’t find any
that shows how to work with dataframe.

Here’s what I have so far:

https://gist.github.com/anonymous/1eab3bea584bb4145cecbbdb4cea8a38

Thanks in advance!

  • Daniel

            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/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/](https://groups.google.com/a/)[continuum.io/d/msgid/bokeh/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io](http://continuum.io/d/msgid/bokeh/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io).

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

  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/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io).

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


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px">
    ](http://continuum.io)

Thanks Sarah.

I have to admit, I am not familiar with that lower level style API on Bokeh. I guess that this style is considered “plotting with basic gylphs” per this documentation:
http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html

I’ve been studying Bokeh’s high level charts api per this documentation since I like to do with DataFrame data structure instead of having to construct the data with dicts:
http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html

Where examples show I just simply pass in a DataFrame.

From your example, I can only deduce or infer that I have to use a loop to draw each individual line or DataFrame’s column by specifying the corresponding x and y values, is that correct?

For example, I tried:
from bokeh.charts import Line, output_notebook, show
from bokeh.models import HoverTool
from bokeh.plotting import figure, ColumnDataSource
import pandas as pd
import numpy as np)
output_notebook()

df = pd.DataFrame(np.random.rand(10, 5), columns=[‘A’, ‘B’, ‘C’, ‘D’, ‘E’])

source = ColumnDataSource(df)
p = figure(plot_width=400, plot_height=400)
for column in df.columns:
line = p.line(x=df.index, y=‘A’, source=source)
line = p.line(x=df.index, y=‘B’, source=source)
line = p.line(x=df.index, y=‘C’, source=source)
line = p.line(x=df.index, y=‘D’, source=source)
p.add_tools(HoverTool(tooltips=“This is %s” % column, renderers=[line]))

output_notebook()

show(p)

It drew the line charts, but the hover tool only worked for one of the lines.

I also can’t seem to find documentation on what the internals of the ColumnDataSource looks like when I instantiate it or pass it with a DataFrame.

If currently, the only way to do the hover tool containing the column names is by using the lower level style api, then I will probably issue a feature request at the github repo to allow for this using the high level api. I just can’t see myself trying to do all that for column names in the hover tooltip. I don’t think it is worth it for me then. In comparison to plotly, plotly generates the hover tool tips for you using their high level api style using cufflinks which very convenient:
https://plot.ly/ipython-notebooks/cufflinks/

  • Daniel

On Thursday, April 28, 2016 at 1:07:35 AM UTC-4, Sarah Bird wrote:

I can only deduce or infer that I have to use a loop to draw
each individual line or DataFrame’s column by specifying the
corresponding x and y values, is that correct?

Yes

> It drew the line charts, but the hover tool only worked for one

of the lines.

You should be setting one line in each iteration of the loop. You

seem to have written out all the lines unnecessarily. Either write
them out or use a for-loop, don’t do both.

source = ColumnDataSource(df)
p = figure(plot_width=400, plot_height=400)
for column in df.columns:
    line = p.line(x=df.index, y=column, source=source)
    p.add_tools(HoverTool(tooltips="This is %s" % column,

renderers=[line]))

···

On 4/28/16 3:15 AM, Daniel wrote:

Thanks Sarah.

    I have to admit, I am not familiar with that lower level style

API on Bokeh. I guess that this style is considered “plotting
with basic gylphs” per this documentation:

    I've been studying Bokeh's high level charts api per this

documentation since I like to do with DataFrame data structure
instead of having to construct the data with dicts:
Where examples show I just simply pass in a DataFrame.
From your example, I can only deduce or infer that I have to use
a loop to draw each individual line or DataFrame’s column by
specifying the corresponding x and y values, is that correct?
For example, I tried:
from bokeh.charts import Line, output_notebook, show
from bokeh.models import HoverTool
from bokeh.plotting import figure, ColumnDataSource
import pandas as pd
import numpy as np)
output_notebook()
df = pd.DataFrame(np.random.rand(10, 5), columns=[‘A’, ‘B’, ‘C’,
‘D’, ‘E’])
source = ColumnDataSource(df)
p = figure(plot_width=400, plot_height=400)
for column in df.columns:
line = p.line(x=df.index, y=‘A’, source=source)
line = p.line(x=df.index, y=‘B’, source=source)
line = p.line(x=df.index, y=‘C’, source=source)
line = p.line(x=df.index, y=‘D’, source=source)
p.add_tools(HoverTool(tooltips=“This is %s” % column,
renderers=[line]))
output_notebook()
show(p)
It drew the line charts, but the hover tool only worked for one
of the lines.
I also can’t seem to find documentation on what the internals of
the ColumnDataSource looks like when I instantiate it or pass it
with a DataFrame.
If currently, the only way to do the hover tool containing the
column names is by using the lower level style api, then I will
probably issue a feature request at the github repo to allow for
this using the high level api. I just can’t see myself trying
to do all that for column names in the hover tooltip. I don’t
think it is worth it for me then. In comparison to plotly,
plotly generates the hover tool tips for you using their high
level api style using cufflinks which very convenient:

  • Daniel
    On Thursday, April 28, 2016 at 1:07:35 AM UTC-4, Sarah Bird
    wrote:

  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/76450073-b7ce-4d77-8db3-0ac537bb6b70%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)

http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html

http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html

https://plot.ly/ipython-notebooks/cufflinks/

Hi Daniel,

              The best way to think about it is that                           Bokeh is really set-up

to be powered by your columns.

                                  If you have a column, you

can use it to power
many different aspects of bokeh - the size, position, color, opacity, … of your points.

                            Each point/shape is a row.



                                                                  So in your

hover tooltip, you can specify @column_name. As
each point is a row then as
you hover ,
the tooltip will pick off
the value for that row of
a
particular
column.

                                                                                                  Lines are

these funn y things
where the “thin g” is the
whole column.

        What

you were hoping to do is completely reasonable, but is not
naturally bokeh-ish if that makes sense.

        There is another thing "multi-line" where each row can hold

the points of a line - this could be a solution except that
hit-testing doesn’t work for multi-line and so there’s no
hover for multi-line.

        Sorry you've stumbled in a funny area. As I said, this is a

great request, and is even hinting at a need for some other
kind of api for line-type things.

        Here's the code to do what you need.

        `

        ``data = {``

        ``    x = [1``,`` 2, 3],``

        ``   col1 = [2, 4, 5],``

        ``   col``2 = [4, 6, 7]``

        ``}``

        ``source = ColumnDataSource(data)``

        ``p = figure()``

        ``for column in ['col1', 'col``2']:``

        ``    ``              line = p.line(x='x', y='col1',

source=source)``

        ``    p.add_``tools(HoverTool(tooltips=``
          "This

is %s" % column, renderers=[line]))`

        data could just as easily be a DataFrame, I just wrote it

like this for clarity

        best,



        bird

On 4/27/16 7:04 PM, Daniel wrote:

            Thanks Sarah.  Not sure I'm getting you,

but it’s probably because I am not well versed in Bokeh
yet. I’ll have to learn it better and get back with
you. I was hoping I would just simply pass df.columns
to the tooltips somehow. Since bokeh is touted to be
tightly integrated with pandas data frames, thought it
would be that easy or at least not having to do a
looping construct.

            On Tuesday, April 26, 2016 at 11:45:47 PM UTC-4, Sarah

Bird wrote:

Hi,

                  That's a nice feature, unfortunately we don't

support it right now. Can I suggest u open a
github issue.

It is possible to do it though.

                  I would probably start with p = figure(), make

one ColumnDataSource, the do a for loop over your
categories, then in each one do :

  1. line = p.line(…) specifying your column
  1. p.add_tools(HoverTool( tooltips=“cat
    name”, renderers=[line]))
                  Sorry, for the brevity, I'm on my phone. Hope

that makes sense.

                  Sarah Bird

[email protected]

                  On Apr 25, 2016, at 8:50 AM, Daniel <                      >

wrote:

Hello,

                        I would like to be able to identify

individual chart series with the hover
tool. I want the column name/series name to
show up on the hover tool. I looked at the
documentation, but I couldn’t find any that
shows how to work with dataframe.

Here’s what I have so far:

https://gist.github.com/anonymous/1eab3bea584bb4145cecbbdb4cea8a38

Thanks in advance!

  • Daniel

                    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 .
To post to this group, send email to .
To view this discussion on the web visit co

          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               .

To view this discussion on the web visit


Sarah Bird
Developer, Bokeh

            [ ![Continuum
                Analytics](https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000) ](http://continuum.io)

[email protected]

[email protected]
[email protected]
https://groups.google.com/a/ntinuum.io/d/msgid/bokeh/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io.

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

                  [email protected]

https://groups.google.com/a/continuum.io/d/msgid/bokeh/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io.

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

        [https://groups.google.com/a/continuum.io/d/msgid/bokeh/76450073-b7ce-4d77-8db3-0ac537bb6b70%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/76450073-b7ce-4d77-8db3-0ac537bb6b70%40continuum.io)

https://groups.google.com/a/continuum.io/d/optout

Thanks Sarah!

I can’t believe I wasn’t using the column variable in that for loop, so embarrassing. That’s what I get for coding at 5am in the morning and no coffee :slight_smile:

I am close. So I am trying to add x and y coordinates to the hover tool also, but I am ending up with two hover tools that overlap where I just want one. I am assuming I am making 2 HoverTool objects. Is there a way to create one HoverTool object and just add tooltips to the same HoverTool object? What complicates things is that one HoverTool object is being made in that for loop, so not sure how to add a tooltip to that one.

This is what I have now:

from bokeh.charts import Line, output_notebook, show
from bokeh.models import HoverTool
from bokeh.plotting import figure, ColumnDataSource
import pandas as pd
import numpy as np
output_notebook()

df = pd.DataFrame(np.random.rand(10, 5), columns=[‘A’, ‘B’, ‘C’, ‘D’, ‘E’])

source = ColumnDataSource(df)
p = figure(plot_width=800, plot_height=400)

Add x,y coordinate to hover tool

p.add_tools(HoverTool(tooltips=[(“(x,y)”, “($x, $y)”)]))

for column in df.columns:
line = p.line(x=df.index, y=column, source=source, line_color=‘black’)
p.add_tools(HoverTool(tooltips=“This is %s” % column, renderers=[line]))

show(p)

···

On Thursday, April 28, 2016 at 4:00:45 PM UTC-4, Sarah Bird wrote:

On 4/28/16 3:15 AM, Daniel wrote:

Hi Daniel,

              The best way to think about it is that                           Bokeh is really set-up

to be powered by your columns.

                                  If you have a column, you

can use it to power
many different aspects of bokeh - the size, position, color, opacity, … of your points.

                            Each point/shape is a row.



                                                                  So in your

hover tooltip, you can specify @column_name. As
each point is a row then as
you hover ,
the tooltip will pick off
the value for that row of
a
particular
column.

                                                                                                  Lines are

these funn y things
where the “thin g” is the
whole column.

        What

you were hoping to do is completely reasonable, but is not
naturally bokeh-ish if that makes sense.

        There is another thing "multi-line" where each row can hold

the points of a line - this could be a solution except that
hit-testing doesn’t work for multi-line and so there’s no
hover for multi-line.

        Sorry you've stumbled in a funny area. As I said, this is a

great request, and is even hinting at a need for some other
kind of api for line-type things.

        Here's the code to do what you need.

        `

        ``data = {``

        ``    x = [1``,`` 2, 3],``

        ``   col1 = [2, 4, 5],``

        ``   col``2 = [4, 6, 7]``

        ``}``

        ``source = ColumnDataSource(data)``

        ``p = figure()``

        ``for column in ['col1', 'col``2']:``

        ``    ``              line = p.line(x='x', y='col1',

source=source)``

        ``    p.add_``tools(HoverTool(tooltips=``
          "This

is %s" % column, renderers=[line]))`

        data could just as easily be a DataFrame, I just wrote it

like this for clarity

        best,



        bird

On 4/27/16 7:04 PM, Daniel wrote:

            Thanks Sarah.  Not sure I'm getting you,

but it’s probably because I am not well versed in Bokeh
yet. I’ll have to learn it better and get back with
you. I was hoping I would just simply pass df.columns
to the tooltips somehow. Since bokeh is touted to be
tightly integrated with pandas data frames, thought it
would be that easy or at least not having to do a
looping construct.

            On Tuesday, April 26, 2016 at 11:45:47 PM UTC-4, Sarah > > > > Bird wrote:

Hi,

                  That's a nice feature, unfortunately we don't

support it right now. Can I suggest u open a
github issue.

It is possible to do it though.

                  I would probably start with p = figure(), make

one ColumnDataSource, the do a for loop over your
categories, then in each one do :

  1. line = p.line(…) specifying your column
  1. p.add_tools(HoverTool( tooltips=“cat
    name”, renderers=[line]))
                  Sorry, for the brevity, I'm on my phone. Hope

that makes sense.

                  Sarah Bird

[email protected]

                  On Apr 25, 2016, at 8:50 AM, Daniel <[email protected]                      > > > > > > wrote:

Hello,

                        I would like to be able to identify

individual chart series with the hover
tool. I want the column name/series name to
show up on the hover tool. I looked at the
documentation, but I couldn’t find any that
shows how to work with dataframe.

Here’s what I have so far:

https://gist.github.com/anonymous/1eab3bea584bb4145cecbbdb4cea8a38

Thanks in advance!

  • Daniel

                    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/)[https://groups.google.com/a/](https://groups.google.com/a/)[continuum.io/d/msgid/bokeh/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io](http://continuum.io/d/msgid/bokeh/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io).

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

          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/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io)[https://groups.google.com/a/](https://groups.google.com/a/)continuum.io/d/msgid/bokeh/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io.

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


Sarah Bird
Developer, Bokeh

            [ <img alt="Continuum
                Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px"> ](http://continuum.io)

Thanks Sarah.

    I have to admit, I am not familiar with that lower level style

API on Bokeh. I guess that this style is considered “plotting
with basic gylphs” per this documentation:

    [http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html](http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html)



    I've been studying Bokeh's high level charts api per this

documentation since I like to do with DataFrame data structure
instead of having to construct the data with dicts:

    [http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html](http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html)



    Where examples show I just simply pass in a DataFrame.



    From your example, I can only deduce or infer that I have to use

a loop to draw each individual line or DataFrame’s column by
specifying the corresponding x and y values, is that correct?

    For example, I tried:

    from bokeh.charts import Line, output_notebook, show

    from bokeh.models import HoverTool

    from bokeh.plotting import figure, ColumnDataSource

    import pandas as pd

    import numpy as np)

    output_notebook()



    df = pd.DataFrame(np.random.rand(        10, 5), columns=['A', 'B', 'C',

‘D’, ‘E’])

    source = ColumnDataSource(df)

    p = figure(plot_width=400, plot_height=400)

    for column in df.columns:

        line = p.line(x=df.index, y='A', source=source)

        line = p.line(x=df.index, y='B', source=source)

        line = p.line(x=df.index, y='C', source=source)

        line = p.line(x=df.index, y='D', source=source)

        p.add_tools(HoverTool(        tooltips="This is %s" % column,

renderers=[line]))

    output_notebook()



    show(p)



    It drew the line charts, but the hover tool only worked for one

of the lines.

    I also can't seem to find documentation on what the internals of

the ColumnDataSource looks like when I instantiate it or pass it
with a DataFrame.

    If currently, the only way to do the hover tool containing the

column names is by using the lower level style api, then I will
probably issue a feature request at the github repo to allow for
this using the high level api. I just can’t see myself trying
to do all that for column names in the hover tooltip. I don’t
think it is worth it for me then. In comparison to plotly,
plotly generates the hover tool tips for you using their high
level api style using cufflinks which very convenient:

    [https://plot.ly/ipython-notebooks/cufflinks/](https://plot.ly/ipython-notebooks/cufflinks/)



    - Daniel



    On Thursday, April 28, 2016 at 1:07:35 AM UTC-4, Sarah Bird > > wrote:

  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/76450073-b7ce-4d77-8db3-0ac537bb6b70%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/76450073-b7ce-4d77-8db3-0ac537bb6b70%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/76450073-b7ce-4d77-8db3-0ac537bb6b70%40continuum.io).

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


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px">
    ](http://continuum.io)
> I can only deduce or infer that I have to use a loop to draw

each individual line or DataFrame’s column by specifying the
corresponding x and y values, is that correct?

Yes



> It drew the line charts, but the hover tool only worked for one

of the lines.

You should be setting one line in each iteration of the loop. You

seem to have written out all the lines unnecessarily. Either write
them out or use a for-loop, don’t do both.

source = ColumnDataSource(df)

p = figure(plot_width=400, plot_height=400)

for column in df.columns:

    line = p.line(x=df.index, y=column, source=source)

    p.add_tools(HoverTool(    tooltips="This is %s" % column,

renderers=[line]))

The first add_tools adds a hover for every render er on the page - that’s the
default behavior when you
don’t specify renderers.

                                  Does the following work

for you:

source = ColumnDataSource(df)

                p = figure(plot_width=800, plot_height=400)

                for column in df.columns:

                    line = p.line(x=df.index, y=column,

source=source, line_color=‘black’)

                                          p.add_tools(

HoverTool( tooltips=[ (“(x,y)”, “($x, $y)”),
(“column”, column), ]))

···

On 4/28/16 3:22 PM, Daniel wrote:

Thanks Sarah!

    I can't believe I wasn't using the column variable in that for

loop, so embarrassing. That’s what I get for coding at 5am in
the morning and no coffee :slight_smile:

    I am close.  So I am trying to add x and y coordinates to the

hover tool also, but I am ending up with two hover tools that
overlap where I just want one. I am assuming I am making 2
HoverTool objects. Is there a way to create one HoverTool
object and just add tooltips to the same HoverTool object? What
complicates things is that one HoverTool object is being made in
that for loop, so not sure how to add a tooltip to that one.

    This is what I have now:



    from bokeh.charts import Line, output_notebook, show

    from bokeh.models import HoverTool

    from bokeh.plotting import figure, ColumnDataSource

    import pandas as pd

    import numpy as np

    output_notebook()



    df = pd.DataFrame(np.random.rand(10, 5), columns=['A', 'B', 'C',

‘D’, ‘E’])

    source = ColumnDataSource(df)

    p = figure(plot_width=800, plot_height=400)



    # Add x,y coordinate to hover tool

    p.add_tools(HoverTool(tooltips=[("(x,y)", "($x, $y)")]))



    for column in df.columns:

        line = p.line(x=df.index, y=column, source=source,

line_color=‘black’)

        p.add_tools(HoverTool(tooltips="This is %s" % column,

renderers=[line]))

    show(p)







    On Thursday, April 28, 2016 at 4:00:45 PM UTC-4, Sarah Bird

wrote:

On 4/28/16 3:15 AM, Daniel wrote:

Hi Daniel,

                      T                              he best way to think

about it is
that Bokeh
is really set-up to be powered by your
columns.

                                                  If you have a

column, you can use
it to power many different aspects of
bokeh - the
size, pos ition, color,
opacity ,
… of your points.

                                    Each point/shape is

a row.

                                                                                  So

in your hover tooltip, you
can specify @column_name .
As each point
is a row then as you
hover , the
tooltip will pick
off the value for
that row of a

                                                      particular

column.

                                                                                                                Lines

are these funn y things
where the
“thin g” is
the whole
column.

                What

you were hoping to do is completely reasonable, but
is not naturally bokeh-ish if that makes sense.

                There is another thing "multi-line" where each row

can hold the points of a line - this could be a
solution except that hit-testing doesn’t work for
multi-line and so there’s no hover for multi-line.

                Sorry you've stumbled in a funny area. As I said,

this is a great request, and is even hinting at a
need for some other kind of api for line-type
things.

                Here's the code to do what you need.

                `

                ``data = {``

                ``    x = [1``,`` 2, 3],``

                ``   col1 = [2, 4, 5],``

                ``   col``2 = [4, 6, 7]``

                ``}``

                ``source = ColumnDataSource(data)``

                ``p = figure()``

                ``for column in ['col1', 'col``2']:``

                ``    ``                      line = p.line(x='x',

y=‘col1’, source=source)``

                ``    p.add_``tools(HoverTool(tooltips=``

                  "This

is %s" % column, renderers=[line]))`

                data could just as easily be a DataFrame, I just

wrote it like this for clarity

                best,



                bird

On 4/27/16 7:04 PM, Daniel wrote:

                    Thanks Sarah.  Not sure I'm getting

you, but it’s probably because I am not well
versed in Bokeh yet. I’ll have to learn it
better and get back with you. I was hoping I
would just simply pass df.columns to the
tooltips somehow. Since bokeh is touted to be
tightly integrated with pandas data frames,
thought it would be that easy or at least not
having to do a looping construct.

                    On Tuesday, April 26, 2016 at 11:45:47 PM UTC-4,

Sarah Bird wrote:

Hi,

                          That's a nice feature, unfortunately we

don’t support it right now. Can I suggest
u open a github issue.

It is possible to do it though.

                          I would probably start with p =

figure(), make one ColumnDataSource, the
do a for loop over your categories, then
in each one do :

                          1) line = p.line(...) specifying your

column

  1. p.add_tools(HoverTool(
    tooltips=“cat
    name”, renderers=[line]))
                          Sorry, for the brevity, I'm on my

phone. Hope that makes sense.

                          Sarah Bird

[email protected]

                          On Apr 25, 2016, at 8:50 AM, Daniel <
                          >

wrote:

Hello,

                                I would like to be able to

identify individual chart series
with the hover tool. I want the
column name/series name to show up
on the hover tool. I looked at the
documentation, but I couldn’t find
any that shows how to work with
dataframe.

Here’s what I have so far:

https://gist.github.com/anonymous/1eab3bea584bb4145cecbbdb4cea8a38

Thanks in advance!

  • Daniel

                            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                                 .

To view this discussion on the web visit
.
For more options, visit co

                  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 .
To post to this group, send email to .
To view this discussion on the web visit co


Sarah Bird
Developer, Bokeh

                    [ ![Continuum Analytics](https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000) ](http://continuum.io)

Thanks Sarah.

            I have to admit, I am not familiar with that lower level

style API on Bokeh. I guess that this style is
considered “plotting with basic gylphs” per this
documentation:

            [http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html](http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html)



            I've been studying Bokeh's high level charts api per

this documentation since I like to do with DataFrame
data structure instead of having to construct the data
with dicts:

            [http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html](http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html)



            Where examples show I just simply pass in a DataFrame.



            From your example, I can only deduce or infer that I

have to use a loop to draw each individual line or
DataFrame’s column by specifying the corresponding x and
y values, is that correct?

            For example, I tried:

            from bokeh.charts import Line, output_notebook, show

            from bokeh.models import HoverTool

            from bokeh.plotting import figure, ColumnDataSource

            import pandas as pd

            import numpy as np)

            output_notebook()



            df = pd.DataFrame(np.random.rand(                10, 5),

columns=[‘A’, ‘B’, ‘C’, ‘D’, ‘E’])

            source = ColumnDataSource(df)

            p = figure(plot_width=400, plot_height=400)

            for column in df.columns:

                line = p.line(x=df.index, y='A', source=source)

                line = p.line(x=df.index, y='B', source=source)

                line = p.line(x=df.index, y='C', source=source)

                line = p.line(x=df.index, y='D', source=source)

                p.add_tools(HoverTool(                tooltips="This is %s" %

column, renderers=[line]))

            output_notebook()



            show(p)



            It drew the line charts, but the hover tool only worked

for one of the lines.

            I also can't seem to find documentation on what the

internals of the ColumnDataSource looks like when I
instantiate it or pass it with a DataFrame.

            If currently, the only way to do the hover tool

containing the column names is by using the lower level
style api, then I will probably issue a feature request
at the github repo to allow for this using the high
level api. I just can’t see myself trying to do all
that for column names in the hover tooltip. I don’t
think it is worth it for me then. In comparison to
plotly, plotly generates the hover tool tips for you
using their high level api style using cufflinks which
very convenient:

            [https://plot.ly/ipython-notebooks/cufflinks/](https://plot.ly/ipython-notebooks/cufflinks/)



            - Daniel



            On Thursday, April 28, 2016 at 1:07:35 AM UTC-4, Sarah

Bird wrote:

          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               .

To view this discussion on the web visit

Sarah Bird
Developer, Bokeh

            [ ![Continuum
                Analytics](https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000) ](http://continuum.io)
        > I can only deduce

or infer that I have to use a loop to draw each individual
line or DataFrame’s column by specifying the corresponding x
and y values, is that correct?

        Yes



        > It drew the line charts, but the hover tool only worked

for one of the lines.

        You should be setting one line in each iteration of the

loop. You seem to have written out all the lines
unnecessarily. Either write them out or use a for-loop,
don’t do both.

        source = ColumnDataSource(df)

        p = figure(plot_width=400, plot_height=400)

        for column in df.columns:

            line = p.line(x=df.index, y=column, source=source)

            p.add_tools(HoverTool(            tooltips="This is %s" %

column, renderers=[line]))

  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/05a22db8-2b49-4625-bdf4-e98b78c706bd%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)

[email protected]

[email protected]
https://groups.google.com/a/continuum.io/d/msgid/bokeh/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io
https://groups.google.com/a/ntinuum.io/d/optout.

                          [email protected]

[email protected]
https://groups.google.com/a/ntinuum.io/d/msgid/bokeh/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io.

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

                [email protected]

https://groups.google.com/a/continuum.io/d/msgid/bokeh/76450073-b7ce-4d77-8db3-0ac537bb6b70%40continuum.io.

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

        [https://groups.google.com/a/continuum.io/d/msgid/bokeh/05a22db8-2b49-4625-bdf4-e98b78c706bd%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/05a22db8-2b49-4625-bdf4-e98b78c706bd%40continuum.io)

https://groups.google.com/a/continuum.io/d/optout

Thanks, it works. Although, it is taking up a lot of CPU or memory. There are long pauses before the hover tool pops up.

Code so far:
from bokeh.charts import Line, output_notebook, show
from bokeh.models import HoverTool
from bokeh.plotting import figure, ColumnDataSource
import pandas as pd
import numpy as np
from itertools import cycle
output_notebook()

df = pd.DataFrame(np.random.rand(10, 5), columns=[‘A’, ‘B’, ‘C’, ‘D’, ‘E’])

colors = [‘black’,‘red’,‘blue’,‘green’]
colorcycler = cycle(colors)

source = ColumnDataSource(df)
p = figure(plot_width=800, plot_height=400)

for column in df.columns:
line = p.line(x=df.index, y=column, source=source, line_color=next(colorcycler))
p.add_tools(HoverTool(tooltips=[(“x,y”,“$x,$y”),(“column”,column),]))

show(p)

···

On Thursday, April 28, 2016 at 6:39:08 PM UTC-4, Sarah Bird wrote:

The first add_tools adds a hover for every render er on the page - that’s the
default behavior when you
don’t specify renderers.

                                  Does the following work

for you:

source = ColumnDataSource(df)

                p = figure(plot_width=800, plot_height=400)



                for column in df.columns:

                    line = p.line(x=df.index, y=column,

source=source, line_color=‘black’)

                                          p.add_tools(

HoverTool( tooltips=[ (“(x,y)”, “($x, $y)”),
(“column”, column), ]))

On 4/28/16 3:22 PM, Daniel wrote:

On 4/28/16 3:15 AM, Daniel wrote:

Hi Daniel,

                      T                              he best way to think

about it is
that Bokeh
is really set-up to be powered by your
columns.

                                                  If you have a

column, you can use
it to power many different aspects of
bokeh - the
size, pos ition, color,
opacity ,
… of your points.

                                    Each point/shape is

a row.

                                                                                  So

in your hover tooltip, you
can specify @column_name .
As each point
is a row then as you
hover , the
tooltip will pick
off the value for
that row of a

                                                      particular

column.

                                                                                                                Lines

are these funn y things
where the
“thin g” is
the whole
column.

                What

you were hoping to do is completely reasonable, but
is not naturally bokeh-ish if that makes sense.

                There is another thing "multi-line" where each row

can hold the points of a line - this could be a
solution except that hit-testing doesn’t work for
multi-line and so there’s no hover for multi-line.

                Sorry you've stumbled in a funny area. As I said,

this is a great request, and is even hinting at a
need for some other kind of api for line-type
things.

                Here's the code to do what you need.

                `

                ``data = {``

                ``    x = [1``,`` 2, 3],``

                ``   col1 = [2, 4, 5],``

                ``   col``2 = [4, 6, 7]``

                ``}``

                ``source = ColumnDataSource(data)``

                ``p = figure()``

                ``for column in ['col1', 'col``2']:``

                ``    ``                      line = p.line(x='x',

y=‘col1’, source=source)``

                ``    p.add_``tools(HoverTool(tooltips=``

                  "This

is %s" % column, renderers=[line]))`

                data could just as easily be a DataFrame, I just

wrote it like this for clarity

                best,



                bird

On 4/27/16 7:04 PM, Daniel wrote:

                    Thanks Sarah.  Not sure I'm getting

you, but it’s probably because I am not well
versed in Bokeh yet. I’ll have to learn it
better and get back with you. I was hoping I
would just simply pass df.columns to the
tooltips somehow. Since bokeh is touted to be
tightly integrated with pandas data frames,
thought it would be that easy or at least not
having to do a looping construct.

                    On Tuesday, April 26, 2016 at 11:45:47 PM UTC-4, > > > > > > Sarah Bird wrote:

Hi,

                          That's a nice feature, unfortunately we

don’t support it right now. Can I suggest
u open a github issue.

It is possible to do it though.

                          I would probably start with p =

figure(), make one ColumnDataSource, the
do a for loop over your categories, then
in each one do :

                          1) line = p.line(...) specifying your

column

  1. p.add_tools(HoverTool(
    tooltips=“cat
    name”, renderers=[line]))
                          Sorry, for the brevity, I'm on my

phone. Hope that makes sense.

                          Sarah Bird

[email protected]

                          On Apr 25, 2016, at 8:50 AM, Daniel <[email protected] > > > > > > >                               > > > > > > > > wrote:

Hello,

                                I would like to be able to

identify individual chart series
with the hover tool. I want the
column name/series name to show up
on the hover tool. I looked at the
documentation, but I couldn’t find
any that shows how to work with
dataframe.

Here’s what I have so far:

https://gist.github.com/anonymous/1eab3bea584bb4145cecbbdb4cea8a38

Thanks in advance!

  • Daniel

                            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/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io.

                            For more options, visit [](https://groups.google.com/a/)[https://groups.google.com/a/](https://groups.google.com/a/)[continuum.io/d/optout](http://continuum.io/d/optout).

                  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/)[https://groups.google.com/a/](https://groups.google.com/a/)[continuum.io/d/msgid/bokeh/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io](http://continuum.io/d/msgid/bokeh/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io).

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


Sarah Bird
Developer, Bokeh

                    [ <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px"> ](http://continuum.io)

Thanks Sarah.

            I have to admit, I am not familiar with that lower level

style API on Bokeh. I guess that this style is
considered “plotting with basic gylphs” per this
documentation:

            [http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html](http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html)



            I've been studying Bokeh's high level charts api per

this documentation since I like to do with DataFrame
data structure instead of having to construct the data
with dicts:

            [http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html](http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html)



            Where examples show I just simply pass in a DataFrame.



            From your example, I can only deduce or infer that I

have to use a loop to draw each individual line or
DataFrame’s column by specifying the corresponding x and
y values, is that correct?

            For example, I tried:

            from bokeh.charts import Line, output_notebook, show

            from bokeh.models import HoverTool

            from bokeh.plotting import figure, ColumnDataSource

            import pandas as pd

            import numpy as np)

            output_notebook()



            df = pd.DataFrame(np.random.rand(                10, 5),

columns=[‘A’, ‘B’, ‘C’, ‘D’, ‘E’])

            source = ColumnDataSource(df)

            p = figure(plot_width=400, plot_height=400)

            for column in df.columns:

                line = p.line(x=df.index, y='A', source=source)

                line = p.line(x=df.index, y='B', source=source)

                line = p.line(x=df.index, y='C', source=source)

                line = p.line(x=df.index, y='D', source=source)

                p.add_tools(HoverTool(                tooltips="This is %s" %

column, renderers=[line]))

            output_notebook()



            show(p)



            It drew the line charts, but the hover tool only worked

for one of the lines.

            I also can't seem to find documentation on what the

internals of the ColumnDataSource looks like when I
instantiate it or pass it with a DataFrame.

            If currently, the only way to do the hover tool

containing the column names is by using the lower level
style api, then I will probably issue a feature request
at the github repo to allow for this using the high
level api. I just can’t see myself trying to do all
that for column names in the hover tooltip. I don’t
think it is worth it for me then. In comparison to
plotly, plotly generates the hover tool tips for you
using their high level api style using cufflinks which
very convenient:

            [https://plot.ly/ipython-notebooks/cufflinks/](https://plot.ly/ipython-notebooks/cufflinks/)



            - Daniel



            On Thursday, April 28, 2016 at 1:07:35 AM UTC-4, Sarah > > > > Bird wrote:

          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/76450073-b7ce-4d77-8db3-0ac537bb6b70%40continuum.io)[https://groups.google.com/a/](https://groups.google.com/a/)continuum.io/d/msgid/bokeh/76450073-b7ce-4d77-8db3-0ac537bb6b70%40continuum.io.

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


Sarah Bird
Developer, Bokeh

            [ <img alt="Continuum
                Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px"> ](http://continuum.io)
        > I can only deduce

or infer that I have to use a loop to draw each individual
line or DataFrame’s column by specifying the corresponding x
and y values, is that correct?

        Yes



        > It drew the line charts, but the hover tool only worked

for one of the lines.

        You should be setting one line in each iteration of the

loop. You seem to have written out all the lines
unnecessarily. Either write them out or use a for-loop,
don’t do both.

        source = ColumnDataSource(df)

        p = figure(plot_width=400, plot_height=400)

        for column in df.columns:

            line = p.line(x=df.index, y=column, source=source)

            p.add_tools(HoverTool(            tooltips="This is %s" %

column, renderers=[line]))

Thanks Sarah!

    I can't believe I wasn't using the column variable in that for

loop, so embarrassing. That’s what I get for coding at 5am in
the morning and no coffee :slight_smile:

    I am close.  So I am trying to add x and y coordinates to the

hover tool also, but I am ending up with two hover tools that
overlap where I just want one. I am assuming I am making 2
HoverTool objects. Is there a way to create one HoverTool
object and just add tooltips to the same HoverTool object? What
complicates things is that one HoverTool object is being made in
that for loop, so not sure how to add a tooltip to that one.

    This is what I have now:



    from bokeh.charts import Line, output_notebook, show

    from bokeh.models import HoverTool

    from bokeh.plotting import figure, ColumnDataSource

    import pandas as pd

    import numpy as np

    output_notebook()



    df = pd.DataFrame(np.random.rand(        10, 5), columns=['A', 'B', 'C',

‘D’, ‘E’])

    source = ColumnDataSource(df)

    p = figure(plot_width=800, plot_height=400)



    # Add x,y coordinate to hover tool

    p.add_tools(HoverTool(tooltips=[("(x,y)", "($x, $y)")]))



    for column in df.columns:

        line = p.line(x=df.index, y=column, source=source,

line_color=‘black’)

        p.add_tools(HoverTool(        tooltips="This is %s" % column,

renderers=[line]))

    show(p)







    On Thursday, April 28, 2016 at 4:00:45 PM UTC-4, Sarah Bird > > wrote:

  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/05a22db8-2b49-4625-bdf4-e98b78c706bd%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/05a22db8-2b49-4625-bdf4-e98b78c706bd%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/05a22db8-2b49-4625-bdf4-e98b78c706bd%40continuum.io).

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


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px">
    ](http://continuum.io)

There was a mistake in
the cod e I wrote, it missed off
specifying the renderers

      for column in df.columns:

            line = p.line(x=df.index, y=column, source=source,

line_color=next(colorcycler), line_width=10)

p.add_tools(HoverTool(tooltips=[(“x,y”,“$x,$y”),(“column”,column),],
renderers=[line]))

···

On 4/28/16 3:50 PM, Daniel wrote:

from bokeh.charts import Line, output_notebook, show

  from bokeh.models import HoverTool

  from bokeh.plotting import figure, ColumnDataSource

  import pandas as pd

  import numpy as np

  from itertools import cycle

  output_notebook()



  df = pd.DataFrame(np.random.rand(10, 5), columns=['A', 'B', 'C',

‘D’, ‘E’])

  colors = ['black','red','blue','green']

  colorcycler = cycle(colors)



  source = ColumnDataSource(df)

  p = figure(plot_width=800, plot_height=400)



  for column in df.columns:

      line = p.line(x=df.index, y=column, source=source,

line_color=next(colorcycler))

p.add_tools(HoverTool(tooltips=[(“x,y”,“$x,$y”),(“column”,column),]))

  show(p)


Sarah Bird
Developer, Bokeh

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

http://nbviewer.jupyter.org/github/birdsarah/bokeh-miscellany/blob/master/hover%20lines.ipynb

···

On 4/28/16 3:50 PM, Daniel wrote:

Thanks, it works. Although, it is taking up a lot of CPU or memory. There are long pauses before the hover tool pops up.

Code so far:
from bokeh.charts import Line, output_notebook, show
from bokeh.models import HoverTool
from bokeh.plotting import figure, ColumnDataSource
import pandas as pd
import numpy as np
from itertools import cycle
output_notebook()

df = pd.DataFrame(np.random.rand(10, 5), columns=['A', 'B', 'C', 'D', 'E'])

colors = ['black','red','blue','green']
colorcycler = cycle(colors)

source = ColumnDataSource(df)
p = figure(plot_width=800, plot_height=400)

for column in df.columns:
    line = p.line(x=df.index, y=column, source=source, line_color=next(colorcycler))
p.add_tools(HoverTool(tooltips=[("x,y","$x,$y"),("column",column),]))

show(p)

On Thursday, April 28, 2016 at 6:39:08 PM UTC-4, Sarah Bird wrote:

    The first add_tools adds a hover for everyrenderer on the page -
    that's the default behavior when you don't specify renderers.

    Does the following work for you:

    source = ColumnDataSource(df)
    p = figure(plot_width=800, plot_height=400)

    for column in df.columns:
        line = p.line(x=df.index, y=column, source=source,
    line_color='black')
        p.add_tools( HoverTool( tooltips=[ ("(x,y)", "($x, $y)"),
    ("column", column), ]))

    On 4/28/16 3:22 PM, Daniel wrote:

    Thanks Sarah!

    I can't believe I wasn't using the column variable in that for
    loop, so embarrassing. That's what I get for coding at 5am in
    the morning and no coffee :slight_smile:

    I am close. So I am trying to add x and y coordinates to the
    hover tool also, but I am ending up with two hover tools that
    overlap where I just want one. I am assuming I am making 2
    HoverTool objects. Is there a way to create one HoverTool object
    and just add tooltips to the same HoverTool object? What
    complicates things is that one HoverTool object is being made in
    that for loop, so not sure how to add a tooltip to that one.

    This is what I have now:

    from bokeh.charts import Line, output_notebook, show
    from bokeh.models import HoverTool
    from bokeh.plotting import figure, ColumnDataSource
    import pandas as pd
    import numpy as np
    output_notebook()

    df = pd.DataFrame(np.random.rand(10, 5), columns=['A', 'B', 'C',
    'D', 'E'])

    source = ColumnDataSource(df)
    p = figure(plot_width=800, plot_height=400)

    # Add x,y coordinate to hover tool
    p.add_tools(HoverTool(tooltips=[("(x,y)", "($x, $y)")]))

    for column in df.columns:
        line = p.line(x=df.index, y=column, source=source,
    line_color='black')
        p.add_tools(HoverTool(tooltips="This is %s" % column,
    renderers=[line]))

    show(p)

    On Thursday, April 28, 2016 at 4:00:45 PM UTC-4, Sarah Bird wrote:

        > I can only deduce or infer that I have to use a loop to
        draw each individual line or DataFrame's column by specifying
        the corresponding x and y values, is that correct?

        Yes

        > It drew the line charts, but the hover tool only worked for
        one of the lines.

        You should be setting one line in each iteration of the loop.
        You seem to have written out all the lines unnecessarily.
        Either write them out or use a for-loop, don't do both.

        source = ColumnDataSource(df)
        p = figure(plot_width=400, plot_height=400)
        for column in df.columns:
            line = p.line(x=df.index, y=column, source=source)
            p.add_tools(HoverTool(tooltips="This is %s" % column,
        renderers=[line]))

        On 4/28/16 3:15 AM, Daniel wrote:

        Thanks Sarah.

        I have to admit, I am not familiar with that lower level
        style API on Bokeh. I guess that this style is considered
        "plotting with basic gylphs" per this documentation:
        http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html
        <http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html&gt;

        I've been studying Bokeh's high level charts api per this
        documentation since I like to do with DataFrame data
        structure instead of having to construct the data with dicts:
        http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html

        Where examples show I just simply pass in a DataFrame.

        From your example, I can only deduce or infer that I have to
        use a loop to draw each individual line or DataFrame's
        column by specifying the corresponding x and y values, is
        that correct?

        For example, I tried:
        from bokeh.charts import Line, output_notebook, show
        from bokeh.models import HoverTool
        from bokeh.plotting import figure, ColumnDataSource
        import pandas as pd
        import numpy as np)
        output_notebook()

        df = pd.DataFrame(np.random.rand(10, 5), columns=['A', 'B',
        'C', 'D', 'E'])

        source = ColumnDataSource(df)
        p = figure(plot_width=400, plot_height=400)
        for column in df.columns:
            line = p.line(x=df.index, y='A', source=source)
            line = p.line(x=df.index, y='B', source=source)
            line = p.line(x=df.index, y='C', source=source)
            line = p.line(x=df.index, y='D', source=source)
            p.add_tools(HoverTool(tooltips="This is %s" % column,
        renderers=[line]))

        output_notebook()

        show(p)

        It drew the line charts, but the hover tool only worked for
        one of the lines.

        I also can't seem to find documentation on what the
        internals of the ColumnDataSource looks like when I
        instantiate it or pass it with a DataFrame.

        If currently, the only way to do the hover tool containing
        the column names is by using the lower level style api, then
        I will probably issue a feature request at the github repo
        to allow for this using the high level api. I just can't
        see myself trying to do all that for column names in the
        hover tooltip. I don't think it is worth it for me then. In comparison to plotly, plotly generates the hover tool
        tips for you using their high level api style using
        cufflinks which very convenient:
        Redirecting…
        <https://plot.ly/ipython-notebooks/cufflinks/&gt;

        - Daniel

        On Thursday, April 28, 2016 at 1:07:35 AM UTC-4, Sarah Bird >>> wrote:

            Hi Daniel,

            The best way to think about it is that Bokeh is really
            set-up to be powered by your columns.

            If you have a column, you can use it to power many
            different aspects of bokeh - the size, position, color,
            opacity, .... of your points.

            Each point/shapeis a row.

            So in your hover tooltip, you can specify @column_name.
            As each point is a row then as you hover, the tooltip
            will pick off the value for that row of aparticular column.

            Lines are these funny things where the "thing" is the
            whole column.

            What you were hoping to do is completely reasonable, but
            is not naturally bokeh-ish if that makes sense.

            There is another thing "multi-line" where each row can
            hold the points of a line - this could be a solution
            except that hit-testing doesn't work for multi-line and
            so there's no hover for multi-line.

            Sorry you've stumbled in a funny area. As I said, this
            is a great request, and is even hinting at a need for
            some other kind of api for line-type things.

            Here's the code to do what you need.

            data = {
                x = [1,2, 3],
               col1 = [2, 4, 5],
               col2 = [4, 6, 7]
            }
            source = ColumnDataSource(data)
            p = figure()
            for column in ['col1', 'col2']:
            line = p.line(x='x', y='col1', source=source)
                p.add_tools(HoverTool(tooltips="This is %s" %
            column, renderers=[line]))

            data could just as easily be a DataFrame, I just wrote
            it like this for clarity

            best,

            bird

            On 4/27/16 7:04 PM, Daniel wrote:

            Thanks Sarah. Not sure I'm getting you, but it's
            probably because I am not well versed in Bokeh yet. I'll have to learn it better and get back with you. I
            was hoping I would just simply pass df.columns to the
            tooltips somehow. Since bokeh is touted to be tightly
            integrated with pandas data frames, thought it would be
            that easy or at least not having to do a looping construct.

            On Tuesday, April 26, 2016 at 11:45:47 PM UTC-4, Sarah >>>> Bird wrote:

                Hi,

                That's a nice feature, unfortunately we don't
                support it right now. Can I suggest u open a github
                issue.

                It is possible to do it though.

                I would probably start with p = figure(), make one
                ColumnDataSource, the do a for loop over your
                categories, then in each one do :
                1) line = p.line(...) specifying your column
                2) p.add_tools(HoverTool(tooltips="cat name",
                renderers=[line]))

                Sorry, for the brevity, I'm on my phone. Hope that
                makes sense.

                Sarah Bird
                sb...@continuum.io

                On Apr 25, 2016, at 8:50 AM, Daniel >>>> <[email protected]> wrote:

                Hello,
                I would like to be able to identify individual
                chart series with the hover tool. I want the
                column name/series name to show up on the hover
                tool. I looked at the documentation, but I
                couldn't find any that shows how to work with
                dataframe.

                Here's what I have so far:
                Bokeh dataframe hover example · GitHub
                <https://gist.github.com/anonymous/1eab3bea584bb4145cecbbdb4cea8a38&gt;

                Thanks in advance!

                - Daniel
                -- 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.
                To post to this group, send email to
                bo...@continuum.io.
                To view this discussion on the web visit
                https://groups.google.com/a/continuum.io/d/msgid/bokeh/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io
                <http://continuum.io/d/msgid/bokeh/dcad6d64-22af-4ec1-9190-166e6f3b5b43%40continuum.io&gt;\.
                For more options, visit
                https://groups.google.com/a/continuum.io/d/optout
                <http://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+un...@continuum.io.
            To post to this group, send email to bo...@continuum.io.
            To view this discussion on the web visit
            https://groups.google.com/a/continuum.io/d/msgid/bokeh/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io
            <http://continuum.io/d/msgid/bokeh/78f7fff1-4794-4970-a55e-d62c94510627%40continuum.io&gt;\.
            For more options, visit
            https://groups.google.com/a/continuum.io/d/optout
            <https://groups.google.com/a/continuum.io/d/optout&gt;\.

            --

            *Sarah Bird*
            */Developer, Bokeh/*

            Continuum Analytics <http://continuum.io>

        -- 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.
        To post to this group, send email to bo...@continuum.io.
        To view this discussion on the web visit
        https://groups.google.com/a/continuum.io/d/msgid/bokeh/76450073-b7ce-4d77-8db3-0ac537bb6b70%40continuum.io\.
        For more options, visit
        https://groups.google.com/a/continuum.io/d/optout
        <https://groups.google.com/a/continuum.io/d/optout&gt;\.

        --

        *Sarah Bird*
        */Developer, Bokeh/*

        Continuum Analytics <http://continuum.io>

    -- 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:>.
    To post to this group, send email to bo...@continuum.io
    <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/a/continuum.io/d/msgid/bokeh/05a22db8-2b49-4625-bdf4-e98b78c706bd%40continuum.io
    <https://groups.google.com/a/continuum.io/d/msgid/bokeh/05a22db8-2b49-4625-bdf4-e98b78c706bd%40continuum.io&gt;\.
    For more options, visit
    https://groups.google.com/a/continuum.io/d/optout
    <https://groups.google.com/a/continuum.io/d/optout&gt;\.

    --

    *Sarah Bird*
    */Developer, Bokeh/*

    Continuum Analytics <http://continuum.io>

--
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] <mailto:[email protected]>.
To post to this group, send email to [email protected] <mailto:[email protected]>.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/53f47518-3075-4ff0-a685-36f5cc3b6b02%40continuum.io <https://groups.google.com/a/continuum.io/d/msgid/bokeh/53f47518-3075-4ff0-a685-36f5cc3b6b02%40continuum.io?utm_medium=email&utm_source=footer&gt;\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--

*Sarah Bird*
*/Developer, Bokeh/*

Continuum Analytics <http://continuum.io>

That was it. Thank you so much Sarah! I am trying to get some intuition on what the renderers do. It was incredible what happens when that is left out. The cpu and RAM usage went through the roof.

  • Daniel
···

On Thursday, April 28, 2016 at 7:04:34 PM UTC-4, Sarah Bird wrote:

    There was a mistake in

the cod e I wrote, it missed off
specifying the renderers

      for column in df.columns:

            line = p.line(x=df.index, y=column, source=source,

line_color=next(colorcycler), line_width=10)

p.add_tools(HoverTool(tooltips=[(“x,y”,“$x,$y”),(" column",column),],
renderers=[line]))

On 4/28/16 3:50 PM, Daniel wrote:

from bokeh.charts import Line, output_notebook, show

  from bokeh.models import HoverTool

  from bokeh.plotting import figure, ColumnDataSource

  import pandas as pd

  import numpy as np

  from itertools import cycle

  output_notebook()



  df = pd.DataFrame(np.random.rand(      10, 5), columns=['A', 'B', 'C',

‘D’, ‘E’])

  colors = ['black','red','blue','green']

  colorcycler = cycle(colors)



  source = ColumnDataSource(df)

  p = figure(plot_width=800, plot_height=400)



  for column in df.columns:

      line = p.line(x=df.index, y=column, source=source,

line_color=next(colorcycler))

p.add_tools(HoverTool(tooltips=[(“x,y”,“$x,$y”),(“column”,column),]))

  show(p)


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px">
    ](http://continuum.io)

You had added 5 hover tools that were each l ooking for whether they were hitting
any of the 5 lines. So you’re doing 5 x as much hit testing
as you need to.

···

On 4/28/16 4:11 PM, Daniel wrote:

    That was it.  Thank you so much Sarah!  I am trying

to get some intuition on what the renderers do. It was
incredible what happens when that is left out. The cpu and RAM
usage went through the roof.

    - Daniel



    On Thursday, April 28, 2016 at 7:04:34 PM UTC-4, Sarah Bird

wrote:

There was a mistake in the cod e I wrote, it missed off
specifying the renderers

              for column in df.columns:

                    line = p.line(x=df.index, y=column,

source=source, line_color=next(colorcycler),
line_width=10)

                    p.add_tools(HoverTool(tooltips=[("x,y","$x,$y"),("
                column",column),],

renderers=[line]))

On 4/28/16 3:50 PM, Daniel wrote:

          from bokeh.charts import Line,

output_notebook, show

          from bokeh.models import HoverTool

          from bokeh.plotting import figure, ColumnDataSource

          import pandas as pd

          import numpy as np

          from itertools import cycle

          output_notebook()



          df = pd.DataFrame(np.random.rand(              10, 5),

columns=[‘A’, ‘B’, ‘C’, ‘D’, ‘E’])

          colors = ['black','red','blue','green']

          colorcycler = cycle(colors)



          source = ColumnDataSource(df)

          p = figure(plot_width=800, plot_height=400)



          for column in df.columns:

              line = p.line(x=df.index, y=column, source=source,

line_color=next(colorcycler))

              p.add_tools(HoverTool(tooltips=[("x,y","$x,$y"),("column",column),]))



          show(p)


Sarah Bird
Developer, Bokeh

            [ ![Continuum
                Analytics](https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000) ](http://continuum.io)

  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/e2ca4b6e-d6ba-42f7-ba06-4517b7123480%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/e2ca4b6e-d6ba-42f7-ba06-4517b7123480%40continuum.io
https://groups.google.com/a/continuum.io/d/optout

Oh ok. So when I specify renderers=[line], I’m basically telling Bokeh to create a hover tool just for that line. Otherwise, it will create a hover tool for all 5 lines. So a renderer or rendered object is like a particular line or bar or any object or thing being drawn/rendered? What exactly constitutes or defines a “renderer”? I think I’m getting it or maybe I am off :-).

I looked at http://bokeh.pydata.org/en/0.11.1/docs/reference/models/renderers.html but there was a lot of OOP speak.

  • Daniel
···

On Thursday, April 28, 2016 at 7:17:08 PM UTC-4, Sarah Bird wrote:

You had added 5 hover tools that were each l ooking for whether they were hitting
any of the 5 lines. So you’re doing 5 x as much hit testing
as you need to.

On 4/28/16 4:11 PM, Daniel wrote:

    That was it.  Thank you so much Sarah!  I am trying

to get some intuition on what the renderers do. It was
incredible what happens when that is left out. The cpu and RAM
usage went through the roof.

    - Daniel



    On Thursday, April 28, 2016 at 7:04:34 PM UTC-4, Sarah Bird > > wrote:

There was a mistake in the cod e I wrote, it missed off
specifying the renderers

              for column in df.columns:

                    line = p.line(x=df.index, y=column,

source=source, line_color=next(colorcycler),
line_width=10)

                    p.add_tools(HoverTool(tooltips=[("x,y","$x,$y"),("
                column",column),],

renderers=[line]))

On 4/28/16 3:50 PM, Daniel wrote:

          from bokeh.charts import Line,

output_notebook, show

          from bokeh.models import HoverTool

          from bokeh.plotting import figure, ColumnDataSource

          import pandas as pd

          import numpy as np

          from itertools import cycle

          output_notebook()



          df = pd.DataFrame(np.random.rand(              10, 5),

columns=[‘A’, ‘B’, ‘C’, ‘D’, ‘E’])

          colors = ['black','red','blue','green']

          colorcycler = cycle(colors)



          source = ColumnDataSource(df)

          p = figure(plot_width=800, plot_height=400)



          for column in df.columns:

              line = p.line(x=df.index, y=column, source=source,

line_color=next(colorcycler))

              p.add_tools(HoverTool(tooltips=[("x,y","$x,$y"),("column",column),]))



          show(p)


Sarah Bird
Developer, Bokeh

            [ <img alt="Continuum
                Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px"> ](http://continuum.io)

  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/e2ca4b6e-d6ba-42f7-ba06-4517b7123480%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/e2ca4b6e-d6ba-42f7-ba06-4517b7123480%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/e2ca4b6e-d6ba-42f7-ba06-4517b7123480%40continuum.io).

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


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px">
    ](http://continuum.io)

A Glyph is a declaration
like a Line, Circle, Rect, etc

      A               GlyphRenderer

is the combination of that Glyph and a data
source.

                T                          his all

happens under
the hood when you
use plotting and charts.

                        But the return                                 value from p.line

( or p.circle
or p.rect or …) is the GlyphRenderer.

                                Bo                                        keh has

other renderers , but
the y’re
no t relevant to hover
tool.

                                          HTH

                                            bird
···

On 4/28/16 4:27 PM, Daniel wrote:

    Oh ok.  So when I specify renderers=[line], I'm

basically telling Bokeh to create a hover tool just for that
line. Otherwise, it will create a hover tool for all 5 lines.
So a renderer or rendered object is like a particular line or
bar or any object or thing being drawn/rendered? What exactly
constitutes or defines a “renderer”? I think I’m getting it or
maybe I am off :-).

    I looked at

but there was a lot of OOP speak.

  • Daniel
    On Thursday, April 28, 2016 at 7:17:08 PM UTC-4, Sarah Bird
    wrote:

  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/9b48faea-ff09-46a3-b073-a216ee4b27bb%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)

http://bokeh.pydata.org/en/0.11.1/docs/reference/models/renderers.html

You had added 5 hover tools that were each l ooking for whether they were
hitting any of the 5 lines. So you’re doing 5 x as
much hit testing as you
need to.

On 4/28/16 4:11 PM, Daniel wrote:

            That was it.  Thank you so much Sarah!  I

am trying to get some intuition on what the renderers
do. It was incredible what happens when that is left
out. The cpu and RAM usage went through the roof.

            - Daniel



            On Thursday, April 28, 2016 at 7:04:34 PM UTC-4, Sarah

Bird wrote:

                    There was a

mistake in the cod e
I wrote, it missed off specifying the
renderers

                                                  for column in

df.columns:

                            line = p.line(x=df.index, y=column,

source=source, line_color=next(colorcycler),
line_width=10)

                            p.add_tools(HoverTool(tooltips=[("x,y","$x,$y"),("

                        column",column),],

renderers=[line]))

On 4/28/16 3:50 PM, Daniel wrote:

                  from bokeh.charts import

Line, output_notebook, show

                  from bokeh.models import HoverTool

                  from bokeh.plotting import figure,

ColumnDataSource

                  import pandas as pd

                  import numpy as np

                  from itertools import cycle

                  output_notebook()



                  df = pd.DataFrame(np.random.rand(                      10, 5),

columns=[‘A’, ‘B’, ‘C’, ‘D’, ‘E’])

                  colors = ['black','red','blue','green']

                  colorcycler = cycle(colors)



                  source = ColumnDataSource(df)

                  p = figure(plot_width=800, plot_height=400)



                  for column in df.columns:

                      line = p.line(x=df.index, y=column,

source=source, line_color=next(colorcycler))

                      p.add_tools(HoverTool(tooltips=[("x,y","$x,$y"),("column",column),]))



                  show(p)


Sarah Bird
Developer, Bokeh

                    [ ![Continuum Analytics](https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000) ](http://continuum.io)

          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               .

To view this discussion on the web visit


Sarah Bird
Developer, Bokeh

            [ ![Continuum
                Analytics](https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000) ](http://continuum.io)

[email protected]
https://groups.google.com/a/continuum.io/d/msgid/bokeh/e2ca4b6e-d6ba-42f7-ba06-4517b7123480%40continuum.io.

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

        [https://groups.google.com/a/continuum.io/d/msgid/bokeh/9b48faea-ff09-46a3-b073-a216ee4b27bb%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/9b48faea-ff09-46a3-b073-a216ee4b27bb%40continuum.io)

https://groups.google.com/a/continuum.io/d/optout

Thanks Sarah for being patient with my questions. You’re awesome! I think I am good for now :slight_smile:

  • Daniel
···

On Thursday, April 28, 2016 at 7:48:27 PM UTC-4, Sarah Bird wrote:

    A Glyph is a declaration

like a Line, Circle, Rect, etc

      A               GlyphRenderer

is the combination of that Glyph and a data
source.

                T                          his all

happens under
the hood when you
use plotting and charts.

                        But the return                                 value from p.line

( or p.circle
or p.rect or …) is the GlyphRenderer.

                                Bo                                        keh has

other renderers , but
the y’re
no t relevant to hover
tool.

                                          HTH



                                            bird

On 4/28/16 4:27 PM, Daniel wrote:

    Oh ok.  So when I specify renderers=[line], I'm

basically telling Bokeh to create a hover tool just for that
line. Otherwise, it will create a hover tool for all 5 lines.
So a renderer or rendered object is like a particular line or
bar or any object or thing being drawn/rendered? What exactly
constitutes or defines a “renderer”? I think I’m getting it or
maybe I am off :-).

    I looked at

http://bokeh.pydata.org/en/0.11.1/docs/reference/models/renderers.html
but there was a lot of OOP speak.

    - Daniel



    On Thursday, April 28, 2016 at 7:17:08 PM UTC-4, Sarah Bird > > wrote:

You had added 5 hover tools that were each l ooking for whether they were
hitting any of the 5 lines. So you’re doing 5 x as
much hit testing as you
need to.

On 4/28/16 4:11 PM, Daniel wrote:

            That was it.  Thank you so much Sarah!  I

am trying to get some intuition on what the renderers
do. It was incredible what happens when that is left
out. The cpu and RAM usage went through the roof.

            - Daniel



            On Thursday, April 28, 2016 at 7:04:34 PM UTC-4, Sarah > > > > Bird wrote:
                    There was a

mistake in the cod e
I wrote, it missed off specifying the
renderers

                                                  for column in

df.columns:

                            line = p.line(x=df.index, y=column,

source=source, line_color=next(colorcycler),
line_width=10)

                            p.add_tools(HoverTool(tooltips=[("x,y","$x,$y"),("

                        column",column),],

renderers=[line]))

On 4/28/16 3:50 PM, Daniel wrote:

                  from bokeh.charts import

Line, output_notebook, show

                  from bokeh.models import HoverTool

                  from bokeh.plotting import figure,

ColumnDataSource

                  import pandas as pd

                  import numpy as np

                  from itertools import cycle

                  output_notebook()



                  df = pd.DataFrame(np.random.rand(                      10, 5),

columns=[‘A’, ‘B’, ‘C’, ‘D’, ‘E’])

                  colors = ['black','red','blue','green']

                  colorcycler = cycle(colors)



                  source = ColumnDataSource(df)

                  p = figure(plot_width=800, plot_height=400)



                  for column in df.columns:

                      line = p.line(x=df.index, y=column,

source=source, line_color=next(colorcycler))

                      p.add_tools(HoverTool(tooltips=[("x,y","$x,$y"),("column",column),]))



                  show(p)


Sarah Bird
Developer, Bokeh

                    [ <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px"> ](http://continuum.io)

          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/e2ca4b6e-d6ba-42f7-ba06-4517b7123480%40continuum.io)[https://groups.google.com/a/](https://groups.google.com/a/)continuum.io/d/msgid/bokeh/e2ca4b6e-d6ba-42f7-ba06-4517b7123480%40continuum.io.

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


Sarah Bird
Developer, Bokeh

            [ <img alt="Continuum
                Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px"> ](http://continuum.io)

  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/9b48faea-ff09-46a3-b073-a216ee4b27bb%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/9b48faea-ff09-46a3-b073-a216ee4b27bb%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/9b48faea-ff09-46a3-b073-a216ee4b27bb%40continuum.io).

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


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px">
    ](http://continuum.io)

Trying to do this as well, and found this 1-yo topic.
@Sarah, is your notebook above currently still the best way to do this?
Thanks!
Tom

···

On Thursday, April 28, 2016 at 7:51:58 PM UTC-4, Daniel wrote:

Thanks Sarah for being patient with my questions. You’re awesome! I think I am good for now :slight_smile:

  • Daniel

On Thursday, April 28, 2016 at 7:48:27 PM UTC-4, Sarah Bird wrote:

    A Glyph is a declaration

like a Line, Circle, Rect, etc

      A               GlyphRenderer

is the combination of that Glyph and a data
source.

                T                          his all

happens under
the hood when you
use plotting and charts.

                        But the return                                 value from p.line

( or p.circle
or p.rect or …) is the GlyphRenderer.

                                Bo                                        keh has

other renderers , but
the y’re
no t relevant to hover
tool.

                                          HTH



                                            bird

On 4/28/16 4:27 PM, Daniel wrote:

    Oh ok.  So when I specify renderers=[line], I'm

basically telling Bokeh to create a hover tool just for that
line. Otherwise, it will create a hover tool for all 5 lines.
So a renderer or rendered object is like a particular line or
bar or any object or thing being drawn/rendered? What exactly
constitutes or defines a “renderer”? I think I’m getting it or
maybe I am off :-).

    I looked at

http://bokeh.pydata.org/en/0.11.1/docs/reference/models/renderers.html
but there was a lot of OOP speak.

    - Daniel



    On Thursday, April 28, 2016 at 7:17:08 PM UTC-4, Sarah Bird > > > wrote:

You had added 5 hover tools that were each l ooking for whether they were
hitting any of the 5 lines. So you’re doing 5 x as
much hit testing as you
need to.

On 4/28/16 4:11 PM, Daniel wrote:

            That was it.  Thank you so much Sarah!  I

am trying to get some intuition on what the renderers
do. It was incredible what happens when that is left
out. The cpu and RAM usage went through the roof.

            - Daniel



            On Thursday, April 28, 2016 at 7:04:34 PM UTC-4, Sarah > > > > > Bird wrote:
                    There was a

mistake in the cod e
I wrote, it missed off specifying the
renderers

                                                  for column in

df.columns:

                            line = p.line(x=df.index, y=column,

source=source, line_color=next(colorcycler),
line_width=10)

                            p.add_tools(HoverTool(tooltips=[("x,y","$x,$y"),("

                        column",column),],

renderers=[line]))

On 4/28/16 3:50 PM, Daniel wrote:

                  from bokeh.charts import

Line, output_notebook, show

                  from bokeh.models import HoverTool

                  from bokeh.plotting import figure,

ColumnDataSource

                  import pandas as pd

                  import numpy as np

                  from itertools import cycle

                  output_notebook()



                  df = pd.DataFrame(np.random.rand(                      10, 5),

columns=[‘A’, ‘B’, ‘C’, ‘D’, ‘E’])

                  colors = ['black','red','blue','green']

                  colorcycler = cycle(colors)



                  source = ColumnDataSource(df)

                  p = figure(plot_width=800, plot_height=400)



                  for column in df.columns:

                      line = p.line(x=df.index, y=column,

source=source, line_color=next(colorcycler))

                      p.add_tools(HoverTool(tooltips=[("x,y","$x,$y"),("column",column),]))



                  show(p)


Sarah Bird
Developer, Bokeh

                    [ <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" width="150px" height="30px"> ](http://continuum.io)

          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/e2ca4b6e-d6ba-42f7-ba06-4517b7123480%40continuum.io)[https://groups.google.com/a/](https://groups.google.com/a/)[continuum.io/d/msgid/bokeh/e2ca4b6e-d6ba-42f7-ba06-4517b7123480%40continuum.io](http://continuum.io/d/msgid/bokeh/e2ca4b6e-d6ba-42f7-ba06-4517b7123480%40continuum.io).

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


Sarah Bird
Developer, Bokeh

            [ <img alt="Continuum
                Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" width="150px" height="30px"> ](http://continuum.io)

  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/9b48faea-ff09-46a3-b073-a216ee4b27bb%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/9b48faea-ff09-46a3-b073-a216ee4b27bb%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/9b48faea-ff09-46a3-b073-a216ee4b27bb%40continuum.io).

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


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" width="150px" height="30px">
    ](http://continuum.io)

I have the same question, can’t find any better solution.

···

вторник, 4 апреля 2017 г., 2:18:52 UTC+3 пользователь Tom S написал:

Trying to do this as well, and found this 1-yo topic.
@Sarah, is your notebook above currently still the best way to do this?
Thanks!
Tom

On Thursday, April 28, 2016 at 7:51:58 PM UTC-4, Daniel wrote:

Thanks Sarah for being patient with my questions. You’re awesome! I think I am good for now :slight_smile:

  • Daniel

On Thursday, April 28, 2016 at 7:48:27 PM UTC-4, Sarah Bird wrote:

    A Glyph is a declaration

like a Line, Circle, Rect, etc

      A               GlyphRenderer

is the combination of that Glyph and a data
source.

                T                          his all

happens under
the hood when you
use plotting and charts.

                        But the return                                 value from p.line

( or p.circle
or p.rect or …) is the GlyphRenderer.

                                Bo                                        keh has

other renderers , but
the y’re
no t relevant to hover
tool.

                                          HTH



                                            bird

On 4/28/16 4:27 PM, Daniel wrote:

    Oh ok.  So when I specify renderers=[line], I'm

basically telling Bokeh to create a hover tool just for that
line. Otherwise, it will create a hover tool for all 5 lines.
So a renderer or rendered object is like a particular line or
bar or any object or thing being drawn/rendered? What exactly
constitutes or defines a “renderer”? I think I’m getting it or
maybe I am off :-).

    I looked at

http://bokeh.pydata.org/en/0.11.1/docs/reference/models/renderers.html
but there was a lot of OOP speak.

    - Daniel



    On Thursday, April 28, 2016 at 7:17:08 PM UTC-4, Sarah Bird > > > > wrote:

You had added 5 hover tools that were each l ooking for whether they were
hitting any of the 5 lines. So you’re doing 5 x as
much hit testing as you
need to.

On 4/28/16 4:11 PM, Daniel wrote:

            That was it.  Thank you so much Sarah!  I

am trying to get some intuition on what the renderers
do. It was incredible what happens when that is left
out. The cpu and RAM usage went through the roof.

            - Daniel



            On Thursday, April 28, 2016 at 7:04:34 PM UTC-4, Sarah > > > > > > Bird wrote:
                    There was a

mistake in the cod e
I wrote, it missed off specifying the
renderers

                                                  for column in

df.columns:

                            line = p.line(x=df.index, y=column,

source=source, line_color=next(colorcycler),
line_width=10)

                            p.add_tools(HoverTool(tooltips=[("x,y","$x,$y"),("

                        column",column),],

renderers=[line]))

On 4/28/16 3:50 PM, Daniel wrote:

                  from bokeh.charts import

Line, output_notebook, show

                  from bokeh.models import HoverTool

                  from bokeh.plotting import figure,

ColumnDataSource

                  import pandas as pd

                  import numpy as np

                  from itertools import cycle

                  output_notebook()



                  df = pd.DataFrame(np.random.rand(                      10, 5),

columns=[‘A’, ‘B’, ‘C’, ‘D’, ‘E’])

                  colors = ['black','red','blue','green']

                  colorcycler = cycle(colors)



                  source = ColumnDataSource(df)

                  p = figure(plot_width=800, plot_height=400)



                  for column in df.columns:

                      line = p.line(x=df.index, y=column,

source=source, line_color=next(colorcycler))

                      p.add_tools(HoverTool(tooltips=[("x,y","$x,$y"),("column",column),]))



                  show(p)


Sarah Bird
Developer, Bokeh

                    [ <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" width="150px" height="30px"> ](http://continuum.io)

          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/e2ca4b6e-d6ba-42f7-ba06-4517b7123480%40continuum.io)[https://groups.google.com/a/](https://groups.google.com/a/)[continuum.io/d/msgid/bokeh/e2ca4b6e-d6ba-42f7-ba06-4517b7123480%40continuum.io](http://continuum.io/d/msgid/bokeh/e2ca4b6e-d6ba-42f7-ba06-4517b7123480%40continuum.io).

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


Sarah Bird
Developer, Bokeh

            [ <img alt="Continuum
                Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" width="150px" height="30px"> ](http://continuum.io)

  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/9b48faea-ff09-46a3-b073-a216ee4b27bb%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/9b48faea-ff09-46a3-b073-a216ee4b27bb%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/9b48faea-ff09-46a3-b073-a216ee4b27bb%40continuum.io).

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


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" width="150px" height="30px">
    ](http://continuum.io)

Has this method been updated? I’ve repeated the code here receive the error:


Supplying a user-defined data source AND iterable values to glyph methods is
not possibe. Either:
Pass all data directly as literals:
p.circe(x=a_list, y=an_array, ...)
Or, put all data in a ColumnDataSource and pass column names:
source = ColumnDataSource(data=dict(x=a_list, y=an_array))
p.circe(x='x', y='y', source=source, ...)
···

On Monday, April 25, 2016 at 8:50:24 AM UTC-7, Daniel wrote:

Hello,

I would like to be able to identify individual chart series with the hover tool. I want the column name/series name to show up on the hover tool. I looked at the documentation, but I couldn’t find any that shows how to work with dataframe.

Here’s what I have so far:

https://gist.github.com/anonymous/1eab3bea584bb4145cecbbdb4cea8a38

Thanks in advance!

  • Daniel