Using column name in hover tool, passing legend to hover tool?

Can a user use the title (header) of a pandas column data set to label a plot name via hover tool? Also, is it possible to pass on a legend to the hover tool (I have a plot with multiple lines).

I see a discussion about this topic at link below but using “@{columan name}” doesn’t seem to work.

Hi,

Please provide example code that demonstrates the problem, that can be tested/examined.

Thanks,

Bryan

···

On May 9, 2017, at 10:35, [email protected] wrote:

Can a user use the title (header) of a pandas column data set to label a plot name via hover tool? Also, is it possible to pass on a legend to the hover tool (I have a plot with multiple lines).

I see a discussion about this topic at link below but using "@{columan name}" doesn't seem to work.
https://github.com/bokeh/bokeh/issues/4796

--
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/264843ae-49b8-460d-8603-ff1e30046ad9%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thank you Bryan,

Here’s a simple sample code with same problem:

import pandas as pd

from bokeh.charts import TimeSeries, show, output_file

from bokeh.layouts import column

from bokeh.models import HoverTool

import pandas as pd

read in some stock data from the Yahoo Finance API

data = pd.DataFrame(np.random.randn(10, 5), columns=[‘a’, ‘b’, ‘c’, ‘d’, ‘e’])

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

p = TimeSeries(data,

x=‘a’, y=[ ‘b’, ‘c’, ‘d’, ‘e’],

title=“Timeseries”, ylabel=‘y’, legend=True, tools = ‘hover’)

hover = p.select(dict(type=HoverTool))

hover.tooltips = [

(“columan_name”, “@{column_name}”),

(“x-value”, “$x”),

(“y-value”, “$y”),

]

output_file(“timeseries.html”)

show(column§)

···

On Tuesday, May 9, 2017 at 11:41:16 AM UTC-4, Bryan Van de ven wrote:

Hi,

Please provide example code that demonstrates the problem, that can be tested/examined.

Thanks,

Bryan

On May 9, 2017, at 10:35, [email protected] wrote:

Can a user use the title (header) of a pandas column data set to label a plot name via hover tool? Also, is it possible to pass on a legend to the hover tool (I have a plot with multiple lines).

I see a discussion about this topic at link below but using “@{columan name}” doesn’t seem to work.
https://github.com/bokeh/bokeh/issues/4796


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/264843ae-49b8-460d-8603-ff1e30046ad9%40continuum.io.

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

Hi,

Sorry for the delay, it's getting hard to keep up with the mailing list volume. To be honest, I would suggest using the bokeh.plotting API instead. There are various ways to do something like the code below, but one minimal way adapted from your code is this:

  import numpy as np
  import pandas as pd

  from bokeh.io import show, output_file
  from bokeh.models import HoverTool, ColumnDataSource
  from bokeh.palettes import Category10
  from bokeh.plotting import figure

  # read in some stock data from the Yahoo Finance API
  df = pd.DataFrame(np.random.randn(10, 5), columns=['a', 'b', 'c', 'd', 'e'])

  source = ColumnDataSource.from_df(df)

  p = figure(plot_width=800)
  for y, c in zip(['b', 'c', 'd', 'e'], Category10[10]):
      p.line('a', y, color=c, legend=y, source=source)

  p.add_tools(HoverTool(tooltips = [
      ("columan_name", "@{column_name}"),
      ("x-value", "$x"),
      ("y-value", "$y"),
  ]))

  output_file("timeseries.html")

  show(p)

Thanks,

Bryan

···

On May 9, 2017, at 11:05, [email protected] wrote:

Thank you Bryan,

Here's a simple sample code with same problem:

import pandas as pd

from bokeh.charts import TimeSeries, show, output_file
from bokeh.layouts import column
from bokeh.models import HoverTool
import pandas as pd

# read in some stock data from the Yahoo Finance API
data = pd.DataFrame(np.random.randn(10, 5), columns=['a', 'b', 'c', 'd', 'e'])

p = figure(plot_height=600, plot_width=800)
p = TimeSeries(data,
    x='a', y=[ 'b', 'c', 'd', 'e'],
    title="Timeseries", ylabel='y', legend=True, tools = 'hover')

hover = p.select(dict(type=HoverTool))
hover.tooltips = [
        ("columan_name", "@{column_name}"),
        ("x-value", "$x"),
        ("y-value", "$y"),
        ]

output_file("timeseries.html")

show(column(p))

On Tuesday, May 9, 2017 at 11:41:16 AM UTC-4, Bryan Van de ven wrote:
Hi,

Please provide example code that demonstrates the problem, that can be tested/examined.

Thanks,

Bryan

> On May 9, 2017, at 10:35, [email protected] wrote:
>
> Can a user use the title (header) of a pandas column data set to label a plot name via hover tool? Also, is it possible to pass on a legend to the hover tool (I have a plot with multiple lines).
>
> I see a discussion about this topic at link below but using "@{columan name}" doesn't seem to work.
> https://github.com/bokeh/bokeh/issues/4796
>
> --
> 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/264843ae-49b8-460d-8603-ff1e30046ad9%40continuum.io.
> For more options, visit 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/61dd36dd-c343-48b7-9bd2-4c94e865be9a%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thank you Bryan for your response. This still doesn’t work. It seems the “”@{column_name}"" part of the code isn’t working.

···

On Tuesday, May 9, 2017 at 11:35:11 AM UTC-4, Shadi G wrote:

Can a user use the title (header) of a pandas column data set to label a plot name via hover tool? Also, is it possible to pass on a legend to the hover tool (I have a plot with multiple lines).

I see a discussion about this topic at link below but using “@{columan name}” doesn’t seem to work.
https://github.com/bokeh/bokeh/issues/4796

I missed that you were trying to have a different value per entire column. Bokeh tooltips are only set up to pull individual values from *inside* columns. If you want something other than this (like the "name" of a column, which is not inside the column), you'd need to use a custom tooltip template. In this case, I'd imagine adding a hover tool for each call to p.line so that the custom template can name the column however you like. Alternatively, you could add a column whose values are all the value of "column_name" that you you want to show up, but that might might expensive/wasteful depending on the size of your data set.

Bryan

···

On May 27, 2017, at 13:32, [email protected] wrote:

Thank you Bryan for your response. This still doesn't work. It seems the ""@{column_name}"" part of the code isn't working.

On Tuesday, May 9, 2017 at 11:35:11 AM UTC-4, Shadi G wrote:
Can a user use the title (header) of a pandas column data set to label a plot name via hover tool? Also, is it possible to pass on a legend to the hover tool (I have a plot with multiple lines).

I see a discussion about this topic at link below but using "@{columan name}" doesn't seem to work.
https://github.com/bokeh/bokeh/issues/4796

--
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/4e1f3a12-fee7-4b2d-b22e-1f430e1d18e8%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.