Tool already has "plot" attribute set

Hi!

I have an issue when specifying tools on a plot with a list in the following way:

from bokeh.models import HoverTool, TapTool, BoxZoomTool, BoxSelectTool, PreviewSaveTool, ResetTool

hover = HoverTool(

tooltips=[

     ("(x,y)", "($x, $y)"),

])

Tools = [hover, TapTool(), BoxZoomTool(), BoxSelectTool(), PreviewSaveTool(), ResetTool()]

figure_obj = figure(plot_width = 1000, plot_height = 800, title = “these are waves”, tools = Tools)

Which throws the following error

ValueError: tool HoverTool, ViewModel:HoverTool, ref _id: 4c7b8138-3e8d-4e0d-8c91-062e91ddfe81 to be added already has ‘plot’ attribute set

I haven’t been able to find any good pointers as to what’s the cause of the problem. Any pointers?

Sincerely,

Robert

Hi Robert,

Tool objects have a .plot attribute that is a "back reference" to the plot that contains them. The add_tools method sets that for you:

  https://github.com/bokeh/bokeh/blob/master/bokeh/models/plots.py#L187

You can either use .add_tools to add the tools on a figure, or set "my_tool.plot = figure_obj" yourself. That said, it's perhaps reasonable that the construction of Figure could do this automatically. An issue or PR woudl certainly be welcome.

Thanks,

Bryan

···

On Feb 15, 2016, at 8:25 AM, Robert <[email protected]> wrote:

Hi!

I have an issue when specifying tools on a plot with a list in the following way:

    from bokeh.models import HoverTool, TapTool, BoxZoomTool, BoxSelectTool, PreviewSaveTool, ResetTool

     hover = HoverTool(
      tooltips=[
       ("(x,y)", "($x, $y)"),
     ])

     Tools = [hover, TapTool(), BoxZoomTool(), BoxSelectTool(), PreviewSaveTool(), ResetTool()]

     figure_obj = figure(plot_width = 1000, plot_height = 800, title = "these are waves", tools = Tools)

Which throws the following error

     ValueError: tool HoverTool, ViewModel:HoverTool, ref _id: 4c7b8138-3e8d-4e0d-8c91-062e91ddfe81 to be added already has 'plot' attribute set

I haven't been able to find any good pointers as to what's the cause of the problem. Any pointers?

Sincerely,
Robert

--
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/d79b70e0-cc24-45e0-8bd4-77373a1a9c02%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hrm, at second glance, I just realize this may be different that what I had thought. Please definitely make an issue. In the mean time, here's an example of one way to configure a hover tool that should work in any case:

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

Or else .add_tools should also work fine:

  https://github.com/bokeh/bokeh/blob/master/examples/models/sprint.py

Thanks,

Bryan

···

On Feb 15, 2016, at 8:35 AM, Bryan Van de Ven <[email protected]> wrote:

Hi Robert,

Tool objects have a .plot attribute that is a "back reference" to the plot that contains them. The add_tools method sets that for you:

  https://github.com/bokeh/bokeh/blob/master/bokeh/models/plots.py#L187

You can either use .add_tools to add the tools on a figure, or set "my_tool.plot = figure_obj" yourself. That said, it's perhaps reasonable that the construction of Figure could do this automatically. An issue or PR woudl certainly be welcome.

Thanks,

Bryan

On Feb 15, 2016, at 8:25 AM, Robert <[email protected]> wrote:

Hi!

I have an issue when specifying tools on a plot with a list in the following way:

   from bokeh.models import HoverTool, TapTool, BoxZoomTool, BoxSelectTool, PreviewSaveTool, ResetTool

    hover = HoverTool(
     tooltips=[
       ("(x,y)", "($x, $y)"),
    ])

    Tools = [hover, TapTool(), BoxZoomTool(), BoxSelectTool(), PreviewSaveTool(), ResetTool()]

    figure_obj = figure(plot_width = 1000, plot_height = 800, title = "these are waves", tools = Tools)

Which throws the following error

    ValueError: tool HoverTool, ViewModel:HoverTool, ref _id: 4c7b8138-3e8d-4e0d-8c91-062e91ddfe81 to be added already has 'plot' attribute set

I haven't been able to find any good pointers as to what's the cause of the problem. Any pointers?

Sincerely,
Robert

--
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/d79b70e0-cc24-45e0-8bd4-77373a1a9c02%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks for the responses, I just posted an issue :slight_smile:

-Robert

···

2016-02-15 15:39 GMT+01:00 Bryan Van de Ven [email protected]:

Hrm, at second glance, I just realize this may be different that what I had thought. Please definitely make an issue. In the mean time, here’s an example of one way to configure a hover tool that should work in any case:

    [https://github.com/bokeh/bokeh/blob/master/examples/plotting/file/hover.py](https://github.com/bokeh/bokeh/blob/master/examples/plotting/file/hover.py)

Or else .add_tools should also work fine:

    [https://github.com/bokeh/bokeh/blob/master/examples/models/sprint.py](https://github.com/bokeh/bokeh/blob/master/examples/models/sprint.py)

Thanks,

Bryan

On Feb 15, 2016, at 8:35 AM, Bryan Van de Ven [email protected] wrote:

Hi Robert,

Tool objects have a .plot attribute that is a “back reference” to the plot that contains them. The add_tools method sets that for you:

  [https://github.com/bokeh/bokeh/blob/master/bokeh/models/plots.py#L187](https://github.com/bokeh/bokeh/blob/master/bokeh/models/plots.py#L187)

You can either use .add_tools to add the tools on a figure, or set “my_tool.plot = figure_obj” yourself. That said, it’s perhaps reasonable that the construction of Figure could do this automatically. An issue or PR woudl certainly be welcome.

Thanks,

Bryan

On Feb 15, 2016, at 8:25 AM, Robert [email protected] wrote:

Hi!

I have an issue when specifying tools on a plot with a list in the following way:

from bokeh.models import HoverTool, TapTool, BoxZoomTool, BoxSelectTool, PreviewSaveTool, ResetTool

hover = HoverTool(
 tooltips=[
      ("(x,y)", "($x, $y)"),
])
Tools = [hover, TapTool(), BoxZoomTool(), BoxSelectTool(), PreviewSaveTool(), ResetTool()]
figure_obj = figure(plot_width = 1000, plot_height = 800, title = "these are waves", tools = Tools)

Which throws the following error

ValueError: tool HoverTool, ViewModel:HoverTool, ref _id: 4c7b8138-3e8d-4e0d-8c91-062e91ddfe81 to be added already has 'plot' attribute set

I haven’t been able to find any good pointers as to what’s the cause of the problem. Any pointers?

Sincerely,

Robert

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/d79b70e0-cc24-45e0-8bd4-77373a1a9c02%40continuum.io.

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

You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/IGYBeZIjrE0/unsubscribe.

To unsubscribe from this group and all its topics, 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/B7A261A2-A1D1-45A7-8439-2B6230AF8593%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.