toolbar disappeared after adding box annotation

I have a strange situation in that when I add a box annotation to a plot, the toolbar disappears. Looking at:

p.toolbar.logo

p.toolbar_location

len(p.toolbar.tools)

reveals that the toolbar is still there (at least on the python side of things), but it is not visible in the web page. I have tried to reproduce in a small example (dumbed down version of my full code), and am unable to reproduce the error. The full example which has the error is kind of difficult to post (and is a mess, so it would be hard to trouble shoot.) Does anyone have any suggestions on how I could troubleshoot further (i.e. how I can tell if python thinks it is visible) and how I could force the toolbar to be visible if I can’t track down what I am doing wrong?

I will continue working on a simplified example…

Thanks,

-james

I was able to reproduce the issue. See attached test file.

Background:

  • There is a layout with a widget box on the left and plots in a layout column on the right.

  • plots are added and removed from the layout column on the right.

  • it is desired to add box annotations to one or more plots.

  • I noticed that there are circumstances which result in the toolbar disappearing when the box annotations are added.

  • see below for more details.

Observe the desired behavior:

  • run the attached file with bokeh server

  • click on the “add_box_annotation” button one or more times.

  • note that a new set box annotations are added to the plot each time.

  • note that the toolbar does not disappear when the box annotations are added.

  • this is the desired behavior.

Observe the undesired behavior:

  • click on the following buttons sequentially:

    • “get data” refreshes the data sources (not really needed for this toy example)
    • “clear column” clears the plots out of the column
    • “plot data” adds two new plots to the column
  • Now that we have our plots back, click on “add box annotation” and observe that the toolbar disappears.

Some observations:

  • If you go to line 171, you will note that I call the get_data(), clear_column(), and plot_data() initially before the layout is added to the root document, so I would think that this should do the same thing as clicking the buttons.

  • Note that I included the sequence twice for good measure to make sure there are not any initialization problems causing the issue.

  • Note that if line 176,177,178 (i.e. the DEBUG block) is commented out, there will not be any plots created from the get-go and then if the buttons are clicked in order (essentially doing the same thing that is happening in the init() function), then the issue will manifest itself. So it seems as if it is not a “2nd time through is messes up” kind of an issue, it is more of a state issue / possibly front end and back end not playing nice with eachother?

  • Note that the first time clear_column() is called, it doesn’t get the following errors to the console window which show up after plots have been added to the column and then removed:

2018-02-05 15:35:03,206 Cannot apply patch to a3c5e63d-b0f9-4cfe-a194-e7771d0ccce6 which is not in the document anymore
2018-02-05 15:35:03,206 Cannot apply patch to a3c5e63d-b0f9-4cfe-a194-e7771d0ccce6 which is not in the document anymore
2018-02-05 15:35:03,222 Cannot apply patch to a3c5e63d-b0f9-4cfe-a194-e7771d0ccce6 which is not in the document anymore
2018-02-05 15:35:03,222 Cannot apply patch to a3c5e63d-b0f9-4cfe-a194-e7771d0ccce6 which is not in the document anymore

  • This may be an issue with how I remove the plots from the column. Is there a better way to remove plots other than the following? Note that the following is actually removing the row children from the column and the row children contain the plots as children:

layout_c.children.pop()

plot_panel_test_04.py (7.12 KB)

···

On Monday, February 5, 2018 at 1:02:21 PM UTC-5, James wrote:

I have a strange situation in that when I add a box annotation to a plot, the toolbar disappears. Looking at:

p.toolbar.logo

p.toolbar_location

len(p.toolbar.tools)

reveals that the toolbar is still there (at least on the python side of things), but it is not visible in the web page. I have tried to reproduce in a small example (dumbed down version of my full code), and am unable to reproduce the error. The full example which has the error is kind of difficult to post (and is a mess, so it would be hard to trouble shoot.) Does anyone have any suggestions on how I could troubleshoot further (i.e. how I can tell if python thinks it is visible) and how I could force the toolbar to be visible if I can’t track down what I am doing wrong?

I will continue working on a simplified example…

Thanks,

-james

Note that removing the children with:

layout_c.children.remove(layout_c.children[len(layout_c.children)-1])

has identical results as using pop()

-james

···

On Monday, February 5, 2018 at 4:17:35 PM UTC-5, James wrote:

I was able to reproduce the issue. See attached test file.

Background:

  • There is a layout with a widget box on the left and plots in a layout column on the right.
  • plots are added and removed from the layout column on the right.
  • it is desired to add box annotations to one or more plots.
  • I noticed that there are circumstances which result in the toolbar disappearing when the box annotations are added.
  • see below for more details.

Observe the desired behavior:

  • run the attached file with bokeh server
  • click on the “add_box_annotation” button one or more times.
  • note that a new set box annotations are added to the plot each time.
  • note that the toolbar does not disappear when the box annotations are added.
  • this is the desired behavior.

Observe the undesired behavior:

  • click on the following buttons sequentially:
    • “get data” refreshes the data sources (not really needed for this toy example)
    • “clear column” clears the plots out of the column
    • “plot data” adds two new plots to the column
  • Now that we have our plots back, click on “add box annotation” and observe that the toolbar disappears.

Some observations:

  • If you go to line 171, you will note that I call the get_data(), clear_column(), and plot_data() initially before the layout is added to the root document, so I would think that this should do the same thing as clicking the buttons.
  • Note that I included the sequence twice for good measure to make sure there are not any initialization problems causing the issue.
  • Note that if line 176,177,178 (i.e. the DEBUG block) is commented out, there will not be any plots created from the get-go and then if the buttons are clicked in order (essentially doing the same thing that is happening in the init() function), then the issue will manifest itself. So it seems as if it is not a “2nd time through is messes up” kind of an issue, it is more of a state issue / possibly front end and back end not playing nice with eachother?
  • Note that the first time clear_column() is called, it doesn’t get the following errors to the console window which show up after plots have been added to the column and then removed:

2018-02-05 15:35:03,206 Cannot apply patch to a3c5e63d-b0f9-4cfe-a194-e7771d0ccce6 which is not in the document anymore
2018-02-05 15:35:03,206 Cannot apply patch to a3c5e63d-b0f9-4cfe-a194-e7771d0ccce6 which is not in the document anymore
2018-02-05 15:35:03,222 Cannot apply patch to a3c5e63d-b0f9-4cfe-a194-e7771d0ccce6 which is not in the document anymore
2018-02-05 15:35:03,222 Cannot apply patch to a3c5e63d-b0f9-4cfe-a194-e7771d0ccce6 which is not in the document anymore

  • This may be an issue with how I remove the plots from the column. Is there a better way to remove plots other than the following? Note that the following is actually removing the row children from the column and the row children contain the plots as children:

layout_c.children.pop()

On Monday, February 5, 2018 at 1:02:21 PM UTC-5, James wrote:

I have a strange situation in that when I add a box annotation to a plot, the toolbar disappears. Looking at:

p.toolbar.logo

p.toolbar_location

len(p.toolbar.tools)

reveals that the toolbar is still there (at least on the python side of things), but it is not visible in the web page. I have tried to reproduce in a small example (dumbed down version of my full code), and am unable to reproduce the error. The full example which has the error is kind of difficult to post (and is a mess, so it would be hard to trouble shoot.) Does anyone have any suggestions on how I could troubleshoot further (i.e. how I can tell if python thinks it is visible) and how I could force the toolbar to be visible if I can’t track down what I am doing wrong?

I will continue working on a simplified example…

Thanks,

-james

Note that replacing instead of deleting then appending children of the column in plot_data() as follows, also results in the same behavior.

this doesn’t work either

if i < len(layout_c.children):
layout_c.children[i] = r
else:
layout_c.children.append®

-james

···

On Monday, February 5, 2018 at 5:21:26 PM UTC-5, James wrote:

Note that removing the children with:

layout_c.children.remove(layout_c.children[len(layout_c.children)-1])

has identical results as using pop()

-james

On Monday, February 5, 2018 at 4:17:35 PM UTC-5, James wrote:

I was able to reproduce the issue. See attached test file.

Background:

  • There is a layout with a widget box on the left and plots in a layout column on the right.
  • plots are added and removed from the layout column on the right.
  • it is desired to add box annotations to one or more plots.
  • I noticed that there are circumstances which result in the toolbar disappearing when the box annotations are added.
  • see below for more details.

Observe the desired behavior:

  • run the attached file with bokeh server
  • click on the “add_box_annotation” button one or more times.
  • note that a new set box annotations are added to the plot each time.
  • note that the toolbar does not disappear when the box annotations are added.
  • this is the desired behavior.

Observe the undesired behavior:

  • click on the following buttons sequentially:
    • “get data” refreshes the data sources (not really needed for this toy example)
    • “clear column” clears the plots out of the column
    • “plot data” adds two new plots to the column
  • Now that we have our plots back, click on “add box annotation” and observe that the toolbar disappears.

Some observations:

  • If you go to line 171, you will note that I call the get_data(), clear_column(), and plot_data() initially before the layout is added to the root document, so I would think that this should do the same thing as clicking the buttons.
  • Note that I included the sequence twice for good measure to make sure there are not any initialization problems causing the issue.
  • Note that if line 176,177,178 (i.e. the DEBUG block) is commented out, there will not be any plots created from the get-go and then if the buttons are clicked in order (essentially doing the same thing that is happening in the init() function), then the issue will manifest itself. So it seems as if it is not a “2nd time through is messes up” kind of an issue, it is more of a state issue / possibly front end and back end not playing nice with eachother?
  • Note that the first time clear_column() is called, it doesn’t get the following errors to the console window which show up after plots have been added to the column and then removed:

2018-02-05 15:35:03,206 Cannot apply patch to a3c5e63d-b0f9-4cfe-a194-e7771d0ccce6 which is not in the document anymore
2018-02-05 15:35:03,206 Cannot apply patch to a3c5e63d-b0f9-4cfe-a194-e7771d0ccce6 which is not in the document anymore
2018-02-05 15:35:03,222 Cannot apply patch to a3c5e63d-b0f9-4cfe-a194-e7771d0ccce6 which is not in the document anymore
2018-02-05 15:35:03,222 Cannot apply patch to a3c5e63d-b0f9-4cfe-a194-e7771d0ccce6 which is not in the document anymore

  • This may be an issue with how I remove the plots from the column. Is there a better way to remove plots other than the following? Note that the following is actually removing the row children from the column and the row children contain the plots as children:

layout_c.children.pop()

On Monday, February 5, 2018 at 1:02:21 PM UTC-5, James wrote:

I have a strange situation in that when I add a box annotation to a plot, the toolbar disappears. Looking at:

p.toolbar.logo

p.toolbar_location

len(p.toolbar.tools)

reveals that the toolbar is still there (at least on the python side of things), but it is not visible in the web page. I have tried to reproduce in a small example (dumbed down version of my full code), and am unable to reproduce the error. The full example which has the error is kind of difficult to post (and is a mess, so it would be hard to trouble shoot.) Does anyone have any suggestions on how I could troubleshoot further (i.e. how I can tell if python thinks it is visible) and how I could force the toolbar to be visible if I can’t track down what I am doing wrong?

I will continue working on a simplified example…

Thanks,

-james

Example of what is expected:

Example of the problem… after plots are removed from the column and added again, subsequently adding box annotations on the plot results in the toolbar disappearing:

Next up to try is to manage a list of plots and show and hide them, similar to the suggestion of showing and hiding box annotations from the plot instead of deleting them, and just manage a list to hide / show provided in this thread:

https://groups.google.com/a/continuum.io/forum/#!mydiscussions/bokeh/wsiTB4r38OM

-james

It looks like as long as you don’t delete the plots, then you are good. Just update the plots and the problem does not express itself.

The update is working without messing up the plots, now need to figure out how to show / hide the figure. Google wasn’t helping out much… Moving on to searching the forum.

-james