Bokeh - HoverTool and legend background color issues

Hi,

I created a Bokeh Plot using following commands (new to bokeh). Unfortunately, two things do not work:

1- I want to get my x, and y values when I hover over my circles:

2- legend.background colors remain “#cccccc”, although, I specify to be “white”.

I appreciate if you could help me on these issues.

Thanks

TOOLS = “resize, pan, wheel_zoom, box_zoom, reset”

p1 = figure(tools = TOOLS, x_axis_label = ‘time (mins)’, y_axis_label = ‘Imbalance’\

, plot_width = 1500, plot_height = 700, background_fill= “#cccccc”)

p1.segment(tempindex, 0, tempindex, df.loc[tempindex, ‘leak_mflow(1)’], line_width=2, line_color=colors[-1])

p1.circle(x = tempindex, y = df.loc[tempindex, ‘leak_mflow(1)’], size=10,\

fill_color=colors[-1], line_color=colors[-1], line_width=3, legend = idx[j][‘name’])

p1.select(dict(type = HoverTool)).tooltips = [{“x”:"$x",“y”:"$y"}]

p1.grid.grid_line_color=“white”

p1.legend.orientation = “bottom_right”

p1.legend.background_fill_color = “white”

p1.legend.background_fill_alpha = 0.2

Do you want x, y data column values, or x, y positions? If you want data values, you want to use @x and @y in your tooltip spec.

Regarding the legend background, I'm not sure, it's working in this User Guide example:

  http://bokeh.pydata.org/en/latest/docs/user_guide/styling.html#id3

And the code there is the actual code that generated that plot. What version of Bokeh are you using?

Bryan

···

On Nov 5, 2015, at 1:17 PM, hkbokeh <[email protected]> wrote:

Hi,

I created a Bokeh Plot using following commands (new to bokeh). Unfortunately, two things do not work:
1- I want to get my x, and y values when I hover over my circles:
2- legend.background colors remain "#cccccc", although, I specify to be "white".

I appreciate if you could help me on these issues.
Thanks

TOOLS = "resize, pan, wheel_zoom, box_zoom, reset"
p1 = figure(tools = TOOLS, x_axis_label = 'time (mins)', y_axis_label = 'Imbalance'\
        , plot_width = 1500, plot_height = 700, background_fill= "#cccccc")

p1.segment(tempindex, 0, tempindex, df.loc[tempindex, 'leak_mflow(1)'], line_width=2, line_color=colors[-1])
p1.circle(x = tempindex, y = df.loc[tempindex, 'leak_mflow(1)'], size=10,\
             fill_color=colors[-1], line_color=colors[-1], line_width=3, legend = idx[j]['name'])

p1.select(dict(type = HoverTool)).tooltips = [{"x":"$x","y":"$y"}]
p1.grid.grid_line_color="white"
p1.legend.orientation = "bottom_right"
p1.legend.background_fill_color = "white"
p1.legend.background_fill_alpha = 0.2

--
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/ecbbf237-fdca-4876-b1df-72a3a9921c56%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

I tried that, it did not help.

···

On Thursday, November 5, 2015 at 2:17:01 PM UTC-5, hkbokeh wrote:

Hi,

I created a Bokeh Plot using following commands (new to bokeh). Unfortunately, two things do not work:

1- I want to get my x, and y values when I hover over my circles:

2- legend.background colors remain “#cccccc”, although, I specify to be “white”.

I appreciate if you could help me on these issues.

Thanks

TOOLS = “resize, pan, wheel_zoom, box_zoom, reset”

p1 = figure(tools = TOOLS, x_axis_label = ‘time (mins)’, y_axis_label = ‘Imbalance’\

, plot_width = 1500, plot_height = 700, background_fill= “#cccccc”)

p1.segment(tempindex, 0, tempindex, df.loc[tempindex, ‘leak_mflow(1)’], line_width=2, line_color=colors[-1])

p1.circle(x = tempindex, y = df.loc[tempindex, ‘leak_mflow(1)’], size=10,\

fill_color=colors[-1], line_color=colors[-1], line_width=3, legend = idx[j][‘name’])

p1.select(dict(type = HoverTool)).tooltips = [{“x”:"$x",“y”:"$y"}]

p1.grid.grid_line_color=“white”

p1.legend.orientation = “bottom_right”

p1.legend.background_fill_color = “white”

p1.legend.background_fill_alpha = 0.2

Is this because of the fact that my x and y are in the loop and they are a single value in every iteration? Should x and y be an array?

···

On Thursday, November 5, 2015 at 2:17:01 PM UTC-5, hkbokeh wrote:

Hi,

I created a Bokeh Plot using following commands (new to bokeh). Unfortunately, two things do not work:

1- I want to get my x, and y values when I hover over my circles:

2- legend.background colors remain “#cccccc”, although, I specify to be “white”.

I appreciate if you could help me on these issues.

Thanks

TOOLS = “resize, pan, wheel_zoom, box_zoom, reset”

p1 = figure(tools = TOOLS, x_axis_label = ‘time (mins)’, y_axis_label = ‘Imbalance’\

, plot_width = 1500, plot_height = 700, background_fill= “#cccccc”)

p1.segment(tempindex, 0, tempindex, df.loc[tempindex, ‘leak_mflow(1)’], line_width=2, line_color=colors[-1])

p1.circle(x = tempindex, y = df.loc[tempindex, ‘leak_mflow(1)’], size=10,\

fill_color=colors[-1], line_color=colors[-1], line_width=3, legend = idx[j][‘name’])

p1.select(dict(type = HoverTool)).tooltips = [{“x”:"$x",“y”:"$y"}]

p1.grid.grid_line_color=“white”

p1.legend.orientation = “bottom_right”

p1.legend.background_fill_color = “white”

p1.legend.background_fill_alpha = 0.2

Actually the problem is probably that when you pass in data explicity, the glyph methods will create a column data source for you with automatic (but probably not human-meaningful) column names. Typically, if you want to extract data from columns you will want to create a column data source explicitly, with column names that mean something to you, and then those are the names you put in the tooltip spec. An example of doing that is here:

  https://github.com/bokeh/bokeh/blob/master/examples/plotting/file/hover.py

Regarding the legend, the background color is a fairly new tunable parameter. I was asking about the version in case you are using a version of Bokeh that is too old.

Bryan

···

On Nov 5, 2015, at 1:24 PM, hkbokeh <[email protected]> wrote:

I tried that, it did not help.

On Thursday, November 5, 2015 at 2:17:01 PM UTC-5, hkbokeh wrote:
Hi,

I created a Bokeh Plot using following commands (new to bokeh). Unfortunately, two things do not work:
1- I want to get my x, and y values when I hover over my circles:
2- legend.background colors remain "#cccccc", although, I specify to be "white".

I appreciate if you could help me on these issues.
Thanks

TOOLS = "resize, pan, wheel_zoom, box_zoom, reset"
p1 = figure(tools = TOOLS, x_axis_label = 'time (mins)', y_axis_label = 'Imbalance'\
        , plot_width = 1500, plot_height = 700, background_fill= "#cccccc")

p1.segment(tempindex, 0, tempindex, df.loc[tempindex, 'leak_mflow(1)'], line_width=2, line_color=colors[-1])
p1.circle(x = tempindex, y = df.loc[tempindex, 'leak_mflow(1)'], size=10,\
             fill_color=colors[-1], line_color=colors[-1], line_width=3, legend = idx[j]['name'])

p1.select(dict(type = HoverTool)).tooltips = [{"x":"$x","y":"$y"}]
p1.grid.grid_line_color="white"
p1.legend.orientation = "bottom_right"
p1.legend.background_fill_color = "white"
p1.legend.background_fill_alpha = 0.2

--
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/9d6a49b1-d5f5-49e5-a2c0-3b82310d1b8d%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hover does not work (for each j, x is an array of integers, y is an array of float points). Please check below.

*p1 = figure(tools = TOOLS, x_axis_label = ‘time (mins)’, y_axis_label = ‘Leak Imbalance (bbls/hr)’*

, plot_width = 1500, plot_height = 700, background_fill= “#cccccc”)

for j in range(3):

for i in range(7):

tempindex = idx[j][‘index’][i]

p1.segment(tempindex, 0, tempindex, df.loc[tempindex, ‘mflow’], line_width=2, line_color=colors[-1])

*p1.circle(tempindex, df.loc[tempindex, ‘leak_mflow(1)’], size=10,*

fill_color=colors[-1], line_color=colors[-1], line_width=3, legend = idx[j][‘name’])

x = idx[j][‘index’]

y = df.loc[x, ‘leak_mflow(1)’].values

p1.select(dict(type = HoverTool)).tooltips = [{“x”:"@x",“y”:"@y"}]

p1.grid.grid_line_color="white"

p1.legend.orientation = "bottom_right"

p1.legend.background_fill_color = "white"

p1.legend.background_fill_alpha = 0.2

***script1, div1 = components(p1) ***

···

On Thursday, November 5, 2015 at 2:17:01 PM UTC-5, hkbokeh wrote:

Hi,

I created a Bokeh Plot using following commands (new to bokeh). Unfortunately, two things do not work:

1- I want to get my x, and y values when I hover over my circles:

2- legend.background colors remain “#cccccc”, although, I specify to be “white”.

I appreciate if you could help me on these issues.

Thanks

TOOLS = “resize, pan, wheel_zoom, box_zoom, reset”

p1 = figure(tools = TOOLS, x_axis_label = ‘time (mins)’, y_axis_label = ‘Imbalance’\

, plot_width = 1500, plot_height = 700, background_fill= “#cccccc”)

p1.segment(tempindex, 0, tempindex, df.loc[tempindex, ‘leak_mflow(1)’], line_width=2, line_color=colors[-1])

p1.circle(x = tempindex, y = df.loc[tempindex, ‘leak_mflow(1)’], size=10,\

fill_color=colors[-1], line_color=colors[-1], line_width=3, legend = idx[j][‘name’])

p1.select(dict(type = HoverTool)).tooltips = [{“x”:"$x",“y”:"$y"}]

p1.grid.grid_line_color=“white”

p1.legend.orientation = “bottom_right”

p1.legend.background_fill_color = “white”

p1.legend.background_fill_alpha = 0.2

Is this a Bug, or I am missing something?

My x and y are python lists and I tried both “@” and “$”, but still it is not working.

Could you please help me regarding this issue?

···

On Thursday, November 5, 2015 at 2:17:01 PM UTC-5, hkbokeh wrote:

Hi,

I created a Bokeh Plot using following commands (new to bokeh). Unfortunately, two things do not work:

1- I want to get my x, and y values when I hover over my circles:

2- legend.background colors remain “#cccccc”, although, I specify to be “white”.

I appreciate if you could help me on these issues.

Thanks

TOOLS = “resize, pan, wheel_zoom, box_zoom, reset”

p1 = figure(tools = TOOLS, x_axis_label = ‘time (mins)’, y_axis_label = ‘Imbalance’\

, plot_width = 1500, plot_height = 700, background_fill= “#cccccc”)

p1.segment(tempindex, 0, tempindex, df.loc[tempindex, ‘leak_mflow(1)’], line_width=2, line_color=colors[-1])

p1.circle(x = tempindex, y = df.loc[tempindex, ‘leak_mflow(1)’], size=10,\

fill_color=colors[-1], line_color=colors[-1], line_width=3, legend = idx[j][‘name’])

p1.select(dict(type = HoverTool)).tooltips = [{“x”:"$x",“y”:"$y"}]

p1.grid.grid_line_color=“white”

p1.legend.orientation = “bottom_right”

p1.legend.background_fill_color = “white”

p1.legend.background_fill_alpha = 0.2

Did you see/check out my previous response with a linked example showing how to use a custom data source? I’m would also still like to know the bokeh version you are using. I can’t tell you much without more information. If the linked example does not help, then can you provide a complete, self-contained, runnable example that demonstrates the issue? There are lots of examples of the hover tool working as expected, so it’s going to be hard to get down to specifics of what’s going awry here without being able to debug actual code.

Thanks,

Bryan

···

On Monday, November 9, 2015 at 12:52:59 PM UTC-2, hkbokeh wrote:

Is this a Bug, or I am missing something?

My x and y are python lists and I tried both “@” and “$”, but still it is not working.

Could you please help me regarding this issue?

On Thursday, November 5, 2015 at 2:17:01 PM UTC-5, hkbokeh wrote:

Hi,

I created a Bokeh Plot using following commands (new to bokeh). Unfortunately, two things do not work:

1- I want to get my x, and y values when I hover over my circles:

2- legend.background colors remain “#cccccc”, although, I specify to be “white”.

I appreciate if you could help me on these issues.

Thanks

TOOLS = “resize, pan, wheel_zoom, box_zoom, reset”

p1 = figure(tools = TOOLS, x_axis_label = ‘time (mins)’, y_axis_label = ‘Imbalance’\

, plot_width = 1500, plot_height = 700, background_fill= “#cccccc”)

p1.segment(tempindex, 0, tempindex, df.loc[tempindex, ‘leak_mflow(1)’], line_width=2, line_color=colors[-1])

p1.circle(x = tempindex, y = df.loc[tempindex, ‘leak_mflow(1)’], size=10,\

fill_color=colors[-1], line_color=colors[-1], line_width=3, legend = idx[j][‘name’])

p1.select(dict(type = HoverTool)).tooltips = [{“x”:"$x",“y”:"$y"}]

p1.grid.grid_line_color=“white”

p1.legend.orientation = “bottom_right”

p1.legend.background_fill_color = “white”

p1.legend.background_fill_alpha = 0.2

My Bokeh version is “bokeh==0.10.0”. I think I copied all details of my code regarding the issue.

···

On Thursday, November 5, 2015 at 2:17:01 PM UTC-5, hkbokeh wrote:

Hi,

I created a Bokeh Plot using following commands (new to bokeh). Unfortunately, two things do not work:

1- I want to get my x, and y values when I hover over my circles:

2- legend.background colors remain “#cccccc”, although, I specify to be “white”.

I appreciate if you could help me on these issues.

Thanks

TOOLS = “resize, pan, wheel_zoom, box_zoom, reset”

p1 = figure(tools = TOOLS, x_axis_label = ‘time (mins)’, y_axis_label = ‘Imbalance’\

, plot_width = 1500, plot_height = 700, background_fill= “#cccccc”)

p1.segment(tempindex, 0, tempindex, df.loc[tempindex, ‘leak_mflow(1)’], line_width=2, line_color=colors[-1])

p1.circle(x = tempindex, y = df.loc[tempindex, ‘leak_mflow(1)’], size=10,\

fill_color=colors[-1], line_color=colors[-1], line_width=3, legend = idx[j][‘name’])

p1.select(dict(type = HoverTool)).tooltips = [{“x”:"$x",“y”:"$y"}]

p1.grid.grid_line_color=“white”

p1.legend.orientation = “bottom_right”

p1.legend.background_fill_color = “white”

p1.legend.background_fill_alpha = 0.2

FWIW, your code example
is definitely not the code you’re actually running given
that TOOLS doesn’t have ‘hover’ in it, yet you’re using p1.select to get at the HoverTool.

                  In addition, your tooltips are                               using a dict which I'm not aware as

supported by tooltips.

                                                          Please supply

an actual code example with dummy data th at illustrates
your problem.

···

On 11/9/15 11:03 AM, hkbokeh wrote:

    My Bokeh version is "bokeh==0.10.0". I think I

copied all details of my code regarding the issue.

      On Thursday, November 5, 2015 at 2:17:01 PM UTC-5, hkbokeh

wrote:

Hi,

            I created a Bokeh Plot using following commands (new

to bokeh). Unfortunately, two things do not work:

            1- I want to get my x, and y values when I hover over

my circles:

            2- legend.background colors remain  "#cccccc",

although, I specify to be “white”.

I appreciate if you could help me on these issues.

Thanks

TOOLS = “resize, pan, wheel_zoom, box_zoom, reset”

              p1 = figure(tools = TOOLS, x_axis_label = 'time

(mins)’, y_axis_label = ‘Imbalance’\

              , plot_width = 1500, plot_height = 700,

background_fill= “#cccccc”)

            p1.segment(tempindex, 0, tempindex, df.loc[tempindex,

‘leak_mflow(1)’], line_width=2, line_color=colors[-1])

              p1.circle(x = tempindex, y = df.loc[tempindex,

‘leak_mflow(1)’], size=10,\

              fill_color=colors[-1],

line_color=colors[-1], line_width=3, legend =
idx[j][‘name’])

              p1.select(dict(type = HoverTool)).tooltips =

[{“x”:"$x",“y”:"$y"}]

p1.grid.grid_line_color=“white”

p1.legend.orientation = “bottom_right”

p1.legend.background_fill_color = “white”

p1.legend.background_fill_alpha = 0.2

  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/87d0b6e9-67d2-4e28-908f-5fc17c3fa7a4%40continuum.io?utm_medium=email&utm_source=footer)      .

For more options, visit .

https://groups.google.com/a/continuum.io/d/msgid/bokeh/87d0b6e9-67d2-4e28-908f-5fc17c3fa7a4%40continuum.io
https://groups.google.com/a/continuum.io/d/optout