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

This change happened years ago. I tried to make the error message self-contained and immediately actionable as to how to update old (now very old) code that mixed CDS column references and literal lists in glyph functions. Can you describe what is unclear about the directions in this exception message so I can try to improve it? The goal is that users can take action immediately without needing to resort to help forums.

Thanks,

Bryan

···

On Aug 1, 2018, at 20:06, [email protected] wrote:

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:
Bokeh dataframe hover example · GitHub

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/46933468-fd06-4335-b930-c5c15563a6c1%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hi Brian, I’m trying to do exactly what the original question was asking. Get the name of the series/column to show up with the hover tool.

I also tried using updated code from the bokeh gallery Interactive legends — Bokeh 3.3.2 Documentation

but alas same result. Here is what I have thus far using the example code from the gallery, again I can’t include the series name in the hover tool.

from bokeh.palettes import Spectral4

from bokeh.models import HoverTool

from bokeh.plotting import figure, output_file, show

from bokeh.sampledata.stocks import AAPL, IBM, MSFT, GOOG

p = figure(plot_width=800, plot_height=400, x_axis_type=“datetime”, tools=‘hover,save’,logo=None)

p.title.text = ‘Click on legend entries to hide the corresponding lines’

for data, name, color in zip([AAPL, IBM, MSFT, GOOG], [“AAPL”, “IBM”, “MSFT”, “GOOG”], Spectral4):

df = pd.DataFrame(data)

df[‘date’] = pd.to_datetime(df[‘date’])

p.line(x=df[‘date’], y=df[‘close’], color=color, alpha=0.8, legend=name)

format tooltips

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

hover.tooltips = [(“Stock”, “name"), ("Date", "@x{%F}"), ("Close", "@{y}{0.2f}”)]

hover.formatters={‘x’: ‘datetime’}

hover.mode = ‘mouse’

p.legend.location = “top_left”

p.legend.click_policy=“hide”

output_file(“interactive_legend.html”, title=“interactive_legend.py example”)

show(p)

Ultimately, I would like to be able to pass a time series dataframe and have the columns serve as labels.

···

On Wednesday, August 1, 2018 at 8:10:01 PM UTC-7, Bryan Van de ven wrote:

This change happened years ago. I tried to make the error message self-contained and immediately actionable as to how to update old (now very old) code that mixed CDS column references and literal lists in glyph functions. Can you describe what is unclear about the directions in this exception message so I can try to improve it? The goal is that users can take action immediately without needing to resort to help forums.

Thanks,

Bryan

On Aug 1, 2018, at 20:06, [email protected] wrote:

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


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/46933468-fd06-4335-b930-c5c15563a6c1%40continuum.io.

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

Hi,

In that case the info about the exception is spurious and unrelated.

Please see the actual documentation for the hover tool:

  https://bokeh.pydata.org/en/latest/docs/user_guide/tools.html#hovertool

Especially re: the recent "$name" variable that was added in the last release. You can refer to a complete example that uses $name here:

  https://bokeh.pydata.org/en/latest/docs/gallery/bar_stacked.html

Thanks,

Bryan

···

On Aug 1, 2018, at 20:16, [email protected] wrote:

Hi Brian, I'm trying to do exactly what the original question was asking. Get the name of the series/column to show up with the hover tool.

I also tried using updated code from the bokeh gallery Interactive legends — Bokeh 3.3.2 Documentation
but alas same result. Here is what I have thus far using the example code from the gallery, again I can't include the series name in the hover tool.

from bokeh.palettes import Spectral4
from bokeh.models import HoverTool

from bokeh.plotting import figure, output_file, show
from bokeh.sampledata.stocks import AAPL, IBM, MSFT, GOOG
p = figure(plot_width=800, plot_height=400, x_axis_type="datetime", tools='hover,save',logo=None)
p.title.text = 'Click on legend entries to hide the corresponding lines'

for data, name, color in zip([AAPL, IBM, MSFT, GOOG], ["AAPL", "IBM", "MSFT", "GOOG"], Spectral4):
    df = pd.DataFrame(data)
    df['date'] = pd.to_datetime(df['date'])
    p.line(x=df['date'], y=df['close'], color=color, alpha=0.8, legend=name)

    # format tooltips
    hover = p.select(dict(type=HoverTool))
    hover.tooltips = [("Stock", "name"\), \("Date", "@x\{%F\}"\), \("Close", "@{y}{0.2f}")]
    hover.formatters={'x': 'datetime'}
    hover.mode = 'mouse'

p.legend.location = "top_left"
p.legend.click_policy="hide"

output_file("interactive_legend.html", title="interactive_legend.py example")

show(p)

Ultimately, I would like to be able to pass a time series dataframe and have the columns serve as labels.

On Wednesday, August 1, 2018 at 8:10:01 PM UTC-7, Bryan Van de ven wrote:
This change happened years ago. I tried to make the error message self-contained and immediately actionable as to how to update old (now very old) code that mixed CDS column references and literal lists in glyph functions. Can you describe what is unclear about the directions in this exception message so I can try to improve it? The goal is that users can take action immediately without needing to resort to help forums.

Thanks,

Bryan

> On Aug 1, 2018, at 20:06, cristian...@king.com wrote:
>
>
> 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:
> Bokeh dataframe hover example · GitHub
>
> 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/46933468-fd06-4335-b930-c5c15563a6c1%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/33a8cae1-d70c-403f-ae48-5a5b6857451c%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

I’ve moved on and intend on using pyviz visualization library (http://pyviz.org/). It has hvplot() function which allows you to make bokeh plots directly from pandas dataframe. Check out https://www.youtube.com/watch?v=aZ1G_Q7ovmc&list=PLYx7XA2nY5Gd-tNhm79CNMe_qvi35PgUR
skip to about 20 minutes.

···

On Wednesday, August 1, 2018 at 11:16:49 PM UTC-4, [email protected] wrote:

Hi Brian, I’m trying to do exactly what the original question was asking. Get the name of the series/column to show up with the hover tool.

I also tried using updated code from the bokeh gallery https://bokeh.pydata.org/en/latest/docs/user_guide/interaction/legends.html

but alas same result. Here is what I have thus far using the example code from the gallery, again I can’t include the series name in the hover tool.

from bokeh.palettes import Spectral4

from bokeh.models import HoverTool

from bokeh.plotting import figure, output_file, show

from bokeh.sampledata.stocks import AAPL, IBM, MSFT, GOOG

p = figure(plot_width=800, plot_height=400, x_axis_type=“datetime”, tools=‘hover,save’,logo=None)

p.title.text = ‘Click on legend entries to hide the corresponding lines’

for data, name, color in zip([AAPL, IBM, MSFT, GOOG], [“AAPL”, “IBM”, “MSFT”, “GOOG”], Spectral4):

df = pd.DataFrame(data)

df[‘date’] = pd.to_datetime(df[‘date’])

p.line(x=df[‘date’], y=df[‘close’], color=color, alpha=0.8, legend=name)

format tooltips

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

hover.tooltips = [(“Stock”, “name"), ("Date", "@x{%F}"), ("Close", "@{y}{0.2f}”)]

hover.formatters={‘x’: ‘datetime’}

hover.mode = ‘mouse’

p.legend.location = “top_left”

p.legend.click_policy=“hide”

output_file(“interactive_legend.html”, title=“interactive_legend.py example”)

show(p)

Ultimately, I would like to be able to pass a time series dataframe and have the columns serve as labels.

On Wednesday, August 1, 2018 at 8:10:01 PM UTC-7, Bryan Van de ven wrote:

This change happened years ago. I tried to make the error message self-contained and immediately actionable as to how to update old (now very old) code that mixed CDS column references and literal lists in glyph functions. Can you describe what is unclear about the directions in this exception message so I can try to improve it? The goal is that users can take action immediately without needing to resort to help forums.

Thanks,

Bryan

On Aug 1, 2018, at 20:06, [email protected] wrote:

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


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/46933468-fd06-4335-b930-c5c15563a6c1%40continuum.io.

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

Hi Bryan, thanks for the quick reply. But it is completely related in the general sense. I use $name in the code snippet I previously sent, doesn’t work. I simply want the name of the column to be reflected in the hover tool. The links you sent me were for examples of dictionaries. The real problem I’m trying to solve is for a time series dataframe with a datetime index and about 200 columns. The columns names are strings, one for each country.

···

On Wednesday, August 1, 2018 at 8:22:32 PM UTC-7, Bryan Van de ven wrote:

Hi,

In that case the info about the exception is spurious and unrelated.

Please see the actual documentation for the hover tool:

    [https://bokeh.pydata.org/en/latest/docs/user_guide/tools.html#hovertool](https://bokeh.pydata.org/en/latest/docs/user_guide/tools.html#hovertool)

Especially re: the recent “$name” variable that was added in the last release. You can refer to a complete example that uses $name here:

    [https://bokeh.pydata.org/en/latest/docs/gallery/bar_stacked.html](https://bokeh.pydata.org/en/latest/docs/gallery/bar_stacked.html)

Thanks,

Bryan

On Aug 1, 2018, at 20:16, [email protected] wrote:

Hi Brian, I’m trying to do exactly what the original question was asking. Get the name of the series/column to show up with the hover tool.

I also tried using updated code from the bokeh gallery https://bokeh.pydata.org/en/latest/docs/user_guide/interaction/legends.html

but alas same result. Here is what I have thus far using the example code from the gallery, again I can’t include the series name in the hover tool.

from bokeh.palettes import Spectral4

from bokeh.models import HoverTool

from bokeh.plotting import figure, output_file, show

from bokeh.sampledata.stocks import AAPL, IBM, MSFT, GOOG

p = figure(plot_width=800, plot_height=400, x_axis_type=“datetime”, tools=‘hover,save’,logo=None)

p.title.text = ‘Click on legend entries to hide the corresponding lines’

for data, name, color in zip([AAPL, IBM, MSFT, GOOG], [“AAPL”, “IBM”, “MSFT”, “GOOG”], Spectral4):

df = pd.DataFrame(data)
df['date'] = pd.to_datetime(df['date'])
p.line(x=df['date'], y=df['close'], color=color, alpha=0.8, legend=name)
# format tooltips
hover = p.select(dict(type=HoverTool))
hover.tooltips = [("Stock", "$name"), ("Date", "@x{%F}"),  ("Close", "$@{y}{0.2f}")]
hover.formatters={'x': 'datetime'}
hover.mode = 'mouse'

p.legend.location = “top_left”

p.legend.click_policy=“hide”

output_file(“interactive_legend.html”, title=“interactive_legend.py example”)

show(p)

Ultimately, I would like to be able to pass a time series dataframe and have the columns serve as labels.

On Wednesday, August 1, 2018 at 8:10:01 PM UTC-7, Bryan Van de ven wrote:

This change happened years ago. I tried to make the error message self-contained and immediately actionable as to how to update old (now very old) code that mixed CDS column references and literal lists in glyph functions. Can you describe what is unclear about the directions in this exception message so I can try to improve it? The goal is that users can take action immediately without needing to resort to help forums.

Thanks,

Bryan

On Aug 1, 2018, at 20:06, [email protected] wrote:

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


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/46933468-fd06-4335-b930-c5c15563a6c1%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/33a8cae1-d70c-403f-ae48-5a5b6857451c%40continuum.io.

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

ah, ok, that sounds like exactly what I need. Thanks!

···

On Wednesday, August 1, 2018 at 8:30:16 PM UTC-7, Daniel wrote:

I’ve moved on and intend on using pyviz visualization library (http://pyviz.org/). It has hvplot() function which allows you to make bokeh plots directly from pandas dataframe. Check out https://www.youtube.com/watch?v=aZ1G_Q7ovmc&list=PLYx7XA2nY5Gd-tNhm79CNMe_qvi35PgUR
skip to about 20 minutes.

On Wednesday, August 1, 2018 at 11:16:49 PM UTC-4, [email protected] wrote:

Hi Brian, I’m trying to do exactly what the original question was asking. Get the name of the series/column to show up with the hover tool.

I also tried using updated code from the bokeh gallery https://bokeh.pydata.org/en/latest/docs/user_guide/interaction/legends.html

but alas same result. Here is what I have thus far using the example code from the gallery, again I can’t include the series name in the hover tool.

from bokeh.palettes import Spectral4

from bokeh.models import HoverTool

from bokeh.plotting import figure, output_file, show

from bokeh.sampledata.stocks import AAPL, IBM, MSFT, GOOG

p = figure(plot_width=800, plot_height=400, x_axis_type=“datetime”, tools=‘hover,save’,logo=None)

p.title.text = ‘Click on legend entries to hide the corresponding lines’

for data, name, color in zip([AAPL, IBM, MSFT, GOOG], [“AAPL”, “IBM”, “MSFT”, “GOOG”], Spectral4):

df = pd.DataFrame(data)

df[‘date’] = pd.to_datetime(df[‘date’])

p.line(x=df[‘date’], y=df[‘close’], color=color, alpha=0.8, legend=name)

format tooltips

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

hover.tooltips = [(“Stock”, “name"), ("Date", "@x{%F}"), ("Close", "@{y}{0.2f}”)]

hover.formatters={‘x’: ‘datetime’}

hover.mode = ‘mouse’

p.legend.location = “top_left”

p.legend.click_policy=“hide”

output_file(“interactive_legend.html”, title=“interactive_legend.py example”)

show(p)

Ultimately, I would like to be able to pass a time series dataframe and have the columns serve as labels.

On Wednesday, August 1, 2018 at 8:10:01 PM UTC-7, Bryan Van de ven wrote:

This change happened years ago. I tried to make the error message self-contained and immediately actionable as to how to update old (now very old) code that mixed CDS column references and literal lists in glyph functions. Can you describe what is unclear about the directions in this exception message so I can try to improve it? The goal is that users can take action immediately without needing to resort to help forums.

Thanks,

Bryan

On Aug 1, 2018, at 20:06, [email protected] wrote:

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


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/46933468-fd06-4335-b930-c5c15563a6c1%40continuum.io.

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

No need, the pyviz devs are colleagues of mine and frequent Bokeh contributors.

Cheers,

Bryan

···

On Aug 1, 2018, at 20:30, Daniel <[email protected]> wrote:

I've moved on and intend on using pyviz visualization library (http://pyviz.org/\). It has hvplot() function which allows you to make bokeh plots directly from pandas dataframe. Check out https://www.youtube.com/watch?v=aZ1G_Q7ovmc&list=PLYx7XA2nY5Gd-tNhm79CNMe_qvi35PgUR skip to about 20 minutes.

On Wednesday, August 1, 2018 at 11:16:49 PM UTC-4, cristian...@king.com wrote:
Hi Brian, I'm trying to do exactly what the original question was asking. Get the name of the series/column to show up with the hover tool.

I also tried using updated code from the bokeh gallery Interactive legends — Bokeh 3.3.2 Documentation
but alas same result. Here is what I have thus far using the example code from the gallery, again I can't include the series name in the hover tool.

from bokeh.palettes import Spectral4
from bokeh.models import HoverTool

from bokeh.plotting import figure, output_file, show
from bokeh.sampledata.stocks import AAPL, IBM, MSFT, GOOG
p = figure(plot_width=800, plot_height=400, x_axis_type="datetime", tools='hover,save',logo=None)
p.title.text = 'Click on legend entries to hide the corresponding lines'

for data, name, color in zip([AAPL, IBM, MSFT, GOOG], ["AAPL", "IBM", "MSFT", "GOOG"], Spectral4):
    df = pd.DataFrame(data)
    df['date'] = pd.to_datetime(df['date'])
    p.line(x=df['date'], y=df['close'], color=color, alpha=0.8, legend=name)

    # format tooltips
    hover = p.select(dict(type=HoverTool))
    hover.tooltips = [("Stock", "name&quot;\), \(&quot;Date&quot;, &quot;@x\{%F\}&quot;\), \(&quot;Close&quot;, &quot;@{y}{0.2f}")]
    hover.formatters={'x': 'datetime'}
    hover.mode = 'mouse'

p.legend.location = "top_left"
p.legend.click_policy="hide"

output_file("interactive_legend.html", title="interactive_legend.py example")

show(p)

Ultimately, I would like to be able to pass a time series dataframe and have the columns serve as labels.

On Wednesday, August 1, 2018 at 8:10:01 PM UTC-7, Bryan Van de ven wrote:
This change happened years ago. I tried to make the error message self-contained and immediately actionable as to how to update old (now very old) code that mixed CDS column references and literal lists in glyph functions. Can you describe what is unclear about the directions in this exception message so I can try to improve it? The goal is that users can take action immediately without needing to resort to help forums.

Thanks,

Bryan

> On Aug 1, 2018, at 20:06, cristian...@king.com wrote:
>
>
> 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:
> Bokeh dataframe hover example · GitHub
>
> 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/46933468-fd06-4335-b930-c5c15563a6c1%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/11b11c8a-0b50-4eb9-9280-6c16bed4ca6b%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hi, as I said, $name is new in the latest release, are you using the latest release? the links I sent use dictionaries for simplicity, but work identically with data frames. Perhaps I should have stated that explicitly.

Cheers,

Bryan

···

On Aug 1, 2018, at 20:33, [email protected] wrote:

Hi Bryan, thanks for the quick reply. But it is completely related in the general sense. I use $name in the code snippet I previously sent, doesn't work. I simply want the name of the column to be reflected in the hover tool. The links you sent me were for examples of dictionaries. The real problem I'm trying to solve is for a time series dataframe with a datetime index and about 200 columns. The columns names are strings, one for each country.

On Wednesday, August 1, 2018 at 8:22:32 PM UTC-7, Bryan Van de ven wrote:
Hi,

In that case the info about the exception is spurious and unrelated.

Please see the actual documentation for the hover tool:

        https://bokeh.pydata.org/en/latest/docs/user_guide/tools.html#hovertool

Especially re: the recent "$name" variable that was added in the last release. You can refer to a complete example that uses $name here:

        https://bokeh.pydata.org/en/latest/docs/gallery/bar_stacked.html

Thanks,

Bryan

> On Aug 1, 2018, at 20:16, cristian...@king.com wrote:
>
> Hi Brian, I'm trying to do exactly what the original question was asking. Get the name of the series/column to show up with the hover tool.
>
> I also tried using updated code from the bokeh gallery Interactive legends — Bokeh 3.3.2 Documentation
> but alas same result. Here is what I have thus far using the example code from the gallery, again I can't include the series name in the hover tool.
>
>
>
> from bokeh.palettes import Spectral4
> from bokeh.models import HoverTool
>
> from bokeh.plotting import figure, output_file, show
> from bokeh.sampledata.stocks import AAPL, IBM, MSFT, GOOG
> p = figure(plot_width=800, plot_height=400, x_axis_type="datetime", tools='hover,save',logo=None)
> p.title.text = 'Click on legend entries to hide the corresponding lines'
>
>
> for data, name, color in zip([AAPL, IBM, MSFT, GOOG], ["AAPL", "IBM", "MSFT", "GOOG"], Spectral4):
> df = pd.DataFrame(data)
> df['date'] = pd.to_datetime(df['date'])
> p.line(x=df['date'], y=df['close'], color=color, alpha=0.8, legend=name)
>
> # format tooltips
> hover = p.select(dict(type=HoverTool))
> hover.tooltips = [("Stock", "name&quot;\), \(&quot;Date&quot;, &quot;@x\{%F\}&quot;\), \(&quot;Close&quot;, &quot;@{y}{0.2f}")]
> hover.formatters={'x': 'datetime'}
> hover.mode = 'mouse'
>
> p.legend.location = "top_left"
> p.legend.click_policy="hide"
>
> output_file("interactive_legend.html", title="interactive_legend.py example")
>
> show(p)
>
>
>
> Ultimately, I would like to be able to pass a time series dataframe and have the columns serve as labels.
>
> On Wednesday, August 1, 2018 at 8:10:01 PM UTC-7, Bryan Van de ven wrote:
> This change happened years ago. I tried to make the error message self-contained and immediately actionable as to how to update old (now very old) code that mixed CDS column references and literal lists in glyph functions. Can you describe what is unclear about the directions in this exception message so I can try to improve it? The goal is that users can take action immediately without needing to resort to help forums.
>
> Thanks,
>
> Bryan
>
> > On Aug 1, 2018, at 20:06, cristian...@king.com wrote:
> >
> >
> > 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:
> > Bokeh dataframe hover example · GitHub
> >
> > 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/46933468-fd06-4335-b930-c5c15563a6c1%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 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/33a8cae1-d70c-403f-ae48-5a5b6857451c%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/3ceb6d1e-b94c-4e7a-91f3-214397b595e6%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Just for completeness, here is a complete bokeh example with data frame using Bokeh 0.13:

import pandas as pd

from bokeh.plotting import figure, output_file, show

df = pd.DataFrame(dict(x=[1,2,3], y1=[4, 5, 2], y2=[6, 8, 7]))

p = figure(tooltips=“name: $name”)

for name in (‘y1’, ‘y2’):
p.line(‘x’, name, source=df, name=name)

output_file(“foo.html”)

show(p)

···

On Aug 1, 2018, at 20:35, Bryan Van de ven [email protected] wrote:

Hi, as I said, $name is new in the latest release, are you using the latest release? the links I sent use dictionaries for simplicity, but work identically with data frames. Perhaps I should have stated that explicitly.

Cheers,

Bryan

On Aug 1, 2018, at 20:33, [email protected] wrote:

Hi Bryan, thanks for the quick reply. But it is completely related in the general sense. I use $name in the code snippet I previously sent, doesn’t work. I simply want the name of the column to be reflected in the hover tool. The links you sent me were for examples of dictionaries. The real problem I’m trying to solve is for a time series dataframe with a datetime index and about 200 columns. The columns names are strings, one for each country.

On Wednesday, August 1, 2018 at 8:22:32 PM UTC-7, Bryan Van de ven wrote:
Hi,

In that case the info about the exception is spurious and unrelated.

Please see the actual documentation for the hover tool:

   [https://bokeh.pydata.org/en/latest/docs/user_guide/tools.html#hovertool](https://bokeh.pydata.org/en/latest/docs/user_guide/tools.html#hovertool) 

Especially re: the recent “$name” variable that was added in the last release. You can refer to a complete example that uses $name here:

   [https://bokeh.pydata.org/en/latest/docs/gallery/bar_stacked.html](https://bokeh.pydata.org/en/latest/docs/gallery/bar_stacked.html) 

Thanks,

Bryan

On Aug 1, 2018, at 20:16, cristian…@king.com wrote:

Hi Brian, I’m trying to do exactly what the original question was asking. Get the name of the series/column to show up with the hover tool.

I also tried using updated code from the bokeh gallery https://bokeh.pydata.org/en/latest/docs/user_guide/interaction/legends.html
but alas same result. Here is what I have thus far using the example code from the gallery, again I can’t include the series name in the hover tool.

from bokeh.palettes import Spectral4
from bokeh.models import HoverTool

from bokeh.plotting import figure, output_file, show
from bokeh.sampledata.stocks import AAPL, IBM, MSFT, GOOG
p = figure(plot_width=800, plot_height=400, x_axis_type=“datetime”, tools=‘hover,save’,logo=None)
p.title.text = ‘Click on legend entries to hide the corresponding lines’

for data, name, color in zip([AAPL, IBM, MSFT, GOOG], [“AAPL”, “IBM”, “MSFT”, “GOOG”], Spectral4):
df = pd.DataFrame(data)
df[‘date’] = pd.to_datetime(df[‘date’])
p.line(x=df[‘date’], y=df[‘close’], color=color, alpha=0.8, legend=name)

format tooltips

hover = p.select(dict(type=HoverTool))
hover.tooltips = [(“Stock”, “name"), ("Date", "@x{%F}"), ("Close", "@{y}{0.2f}”)]
hover.formatters={‘x’: ‘datetime’}
hover.mode = ‘mouse’

p.legend.location = “top_left”
p.legend.click_policy=“hide”

output_file(“interactive_legend.html”, title=“interactive_legend.py example”)

show(p)

Ultimately, I would like to be able to pass a time series dataframe and have the columns serve as labels.

On Wednesday, August 1, 2018 at 8:10:01 PM UTC-7, Bryan Van de ven wrote:
This change happened years ago. I tried to make the error message self-contained and immediately actionable as to how to update old (now very old) code that mixed CDS column references and literal lists in glyph functions. Can you describe what is unclear about the directions in this exception message so I can try to improve it? The goal is that users can take action immediately without needing to resort to help forums.

Thanks,

Bryan

On Aug 1, 2018, at 20:06, cristian…@king.com wrote:

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


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/46933468-fd06-4335-b930-c5c15563a6c1%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 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/33a8cae1-d70c-403f-ae48-5a5b6857451c%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/3ceb6d1e-b94c-4e7a-91f3-214397b595e6%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

1 Like

ah, perfect! Thank you! I’m geeking out on the holoviews video you sent.

-Cristian Heredia

···

On Wednesday, August 1, 2018 at 8:42:05 PM UTC-7, Bryan Van de ven wrote:

Just for completeness, here is a complete bokeh example with data frame using Bokeh 0.13:

import pandas as pd

from bokeh.plotting import figure, output_file, show

df = pd.DataFrame(dict(x=[1,2,3], y1=[4, 5, 2], y2=[6, 8, 7]))

p = figure(tooltips=“name: $name”)

for name in (‘y1’, ‘y2’):
p.line(‘x’, name, source=df, name=name)

output_file(“foo.html”)

show(p)

On Aug 1, 2018, at 20:35, Bryan Van de ven [email protected] wrote:

Hi, as I said, $name is new in the latest release, are you using the latest release? the links I sent use dictionaries for simplicity, but work identically with data frames. Perhaps I should have stated that explicitly.

Cheers,

Bryan

On Aug 1, 2018, at 20:33, [email protected] wrote:

Hi Bryan, thanks for the quick reply. But it is completely related in the general sense. I use $name in the code snippet I previously sent, doesn’t work. I simply want the name of the column to be reflected in the hover tool. The links you sent me were for examples of dictionaries. The real problem I’m trying to solve is for a time series dataframe with a datetime index and about 200 columns. The columns names are strings, one for each country.

On Wednesday, August 1, 2018 at 8:22:32 PM UTC-7, Bryan Van de ven wrote:
Hi,

In that case the info about the exception is spurious and unrelated.

Please see the actual documentation for the hover tool:

   [https://bokeh.pydata.org/en/latest/docs/user_guide/tools.html#hovertool](https://bokeh.pydata.org/en/latest/docs/user_guide/tools.html#hovertool) 

Especially re: the recent “$name” variable that was added in the last release. You can refer to a complete example that uses $name here:

   [https://bokeh.pydata.org/en/latest/docs/gallery/bar_stacked.html](https://bokeh.pydata.org/en/latest/docs/gallery/bar_stacked.html) 

Thanks,

Bryan

On Aug 1, 2018, at 20:06, cristian…@king.com wrote:

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


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/46933468-fd06-4335-b930-c5c15563a6c1%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
On Aug 1, 2018, at 20:16, cristian…@king.com wrote:

Hi Brian, I’m trying to do exactly what the original question was asking. Get the name of the series/column to show up with the hover tool.

I also tried using updated code from the bokeh gallery https://bokeh.pydata.org/en/latest/docs/user_guide/interaction/legends.html
but alas same result. Here is what I have thus far using the example code from the gallery, again I can’t include the series name in the hover tool.

from bokeh.palettes import Spectral4
from bokeh.models import HoverTool

from bokeh.plotting import figure, output_file, show
from bokeh.sampledata.stocks import AAPL, IBM, MSFT, GOOG
p = figure(plot_width=800, plot_height=400, x_axis_type=“datetime”, tools=‘hover,save’,logo=None)
p.title.text = ‘Click on legend entries to hide the corresponding lines’

for data, name, color in zip([AAPL, IBM, MSFT, GOOG], [“AAPL”, “IBM”, “MSFT”, “GOOG”], Spectral4):
df = pd.DataFrame(data)
df[‘date’] = pd.to_datetime(df[‘date’])
p.line(x=df[‘date’], y=df[‘close’], color=color, alpha=0.8, legend=name)

format tooltips

hover = p.select(dict(type=HoverTool))
hover.tooltips = [(“Stock”, “name"), ("Date", "@x{%F}"), ("Close", "@{y}{0.2f}”)]
hover.formatters={‘x’: ‘datetime’}
hover.mode = ‘mouse’

p.legend.location = “top_left”
p.legend.click_policy=“hide”

output_file(“interactive_legend.html”, title=“interactive_legend.py example”)

show(p)

Ultimately, I would like to be able to pass a time series dataframe and have the columns serve as labels.

On Wednesday, August 1, 2018 at 8:10:01 PM UTC-7, Bryan Van de ven wrote:
This change happened years ago. I tried to make the error message self-contained and immediately actionable as to how to update old (now very old) code that mixed CDS column references and literal lists in glyph functions. Can you describe what is unclear about the directions in this exception message so I can try to improve it? The goal is that users can take action immediately without needing to resort to help forums.

Thanks,

Bryan


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/33a8cae1-d70c-403f-ae48-5a5b6857451c%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/3ceb6d1e-b94c-4e7a-91f3-214397b595e6%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hello, Bryan,

Your solution is very easy to use.
Nevertheless, when I use a string list for the x-axis it doesn’t work. There are no errors but there is nothing on the graph.
What could cause that?

Also, how the “Y” values can be added to the tooltip as well?

Thank you!

@KAM please ask a open a new question rather than resurrecting a very old thread, and also be sure to include some actual code that shows what you are trying.

Hello, Bryan,

I thought that it would be better to ask it here because it is a follow-up to your response.
Nevertheless, I’ve managed somehow to fix it and it is working now.
Here is a code snippet:

df_1st_2nd = pd.DataFrame(dict(x=x, y14=churn_40d_12m_1st, y24=churn_40d_12m_2nd,
y34=difference_1st_2nd))
source_1st_2nd = ColumnDataSource(df_1st_2nd)
fig1 = figure(x_range=x, y_range=[0, 1], plot_width=1500, plot_height=600, tooltips=[
(‘Line Name’, ‘$name’),
(‘Value’, ‘$y{0 %}’)
])
i = 1

for name in (“y1”, “y2”, “y3”, “y4”):
if i == 1:
line1 = fig1.line(‘x’, name, source=source_3d, name=“line1”, color=‘green’, line_width=2)
circle1 = fig1.circle(‘x’, name, source=source_3d, name=“line1”, color=‘green’)
elif i == 2:
line2 = fig1.line(‘x’, name, source=source_3d, name=“line2”, color=‘blue’, line_width=2)
circle2 = fig1.circle(‘x’, name, source=source_3d, name=“line2”, color=‘blue’)
elif i == 3:
line3 = fig1.line(‘x’, name, source=source_3d, name=“line3”, color=‘brown’, line_width=2)
circle3 = fig1.circle(‘x’, name, source=source_3d, name=“line3”, color=‘brown’)
elif i == 4:
line4 = fig1.line(‘x’, name, source=source_3d, name=“line4”, color=‘red’, line_width=2)
circle4 = fig1.circle(‘x’, name, source=source_3d, name=“line4”, color=‘red’)
i = i + 1