In short:
Using Bokeh Server, I can add and delete box annotations no problem prior to the plot being displayed using some helper functions. However, once the plot is displayed to the user, I can add box annotations with call-backs, but can not delete the box annotations using callback buttons and the exact same helper functions. If it was a scope issue, I would expect add and delete to either both work, or both not work.
In detail:
To see what I mean, go to line 138 where the debugging code starts in the attached python file and follow the instructions for Debug 1,2,3,4 which are repeated here for clarity
It appears as if although the box annotations are added and they can be found immediately after adding while still within the scope of the add_box_annotations() function as seen by the output produced to standard out from line 65. However, immediately after exiting that function, the box annotations can no longer be found in the same figure object “f” as seen by the lack of output provided to standard out from the add_box_annotations_handler() function in line 96.
annotation_test_9.py (5 KB)
···
#======================
initialize the layout
f = draw_plot3()
Debug 1:
uncommenting the following results in the expected behavior of box annotations
being added to the plot when the plot is first displayed to the user.
#add_box_annotations(f)
Debug 2:
uncommenting the previous along with following results in the expected behavior
of the box annotations being removed prior to the plot being displayed to the
user for the first time.
#clear_box_annotations(f)
Debug 3:
clicking on the “add” button results in the expected behavior of box annotations
being added.
Debug 4:
clicking on the “delete” button (with an annotation displayed) results in the
unexpected behavior of nothing getting deleted.
Please advise,
Thanks!
-james
============
bokeh serve annotation_test_9.py --show
Bokeh Server 0.12.13
python 3.5


