Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] fig.add_layout doesn't update the figure. #8862

smamyris opened this issue Apr 23, 2019 · 4 comments · Fixed by #9928

[BUG] fig.add_layout doesn't update the figure. #8862

smamyris opened this issue Apr 23, 2019 · 4 comments · Fixed by #9928


Copy link

smamyris commented Apr 23, 2019

Python 3.5
Bokeh 1.1.0
Tornado 6.0.2

Running a Bokeh server, in 1.0.3 the following code snippet adds a span and box annotation to fig whenever button is clicked. In 1.1.0 the on_click event still runs, but fig doesn't update.
I didn't see anything related in the release notes, so I assume this is not the intended behavior.
I would appreciate any feedback on whether this is reproducible on other machines and potential workarounds.

from bokeh.plotting import Figure
from bokeh.models import Span, BoxAnnotation
from import curdoc
from bokeh.layouts import column, row
from bokeh.models.widgets import Button

def addAnnotations():
    span = Span(location=3, dimension='width',
              line_color='red', line_dash='dashed',
    box = BoxAnnotation(top=5, bottom=2, fill_alpha=0.1, fill_color='green')

fig = Figure(width=1000, height=500)
cir =[1, 2, 3], y=[3, 4, 5])

button = Button(label='Add Annotation', width=300)

layout = column(row(button),row(fig))

Copy link

bryevdv commented Apr 23, 2019

definitely a bug @smamyris thanks for the detailed report

cc @mattpap any thoughts?

Copy link

smamyris commented Apr 23, 2019

Thanks for looking into it.
As a workaround manipulating the renderers attribute directly triggers the update correctly.

@mattpap mattpap modified the milestones: 1.1.1, short-term Apr 29, 2019
Copy link

happydasch commented Jul 29, 2019

with bokeh 1.3.0, when adding Annotations (tried it with Label and Span) after the plot was shown, the Annotations do not show up. Workaround for me is to remove the plot from layout and then add it again or to extend the renderers: plot.renderers.extend([span, label])

Copy link

p-himik commented Mar 15, 2020

An alternative, more lightweight, workaround:

plot.js_on_change('center', CustomJS(args=dict(plot=plot),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging a pull request may close this issue.

5 participants