Skip to content

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

@smamyris

Description

@smamyris

Environment:
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 bokeh.io 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',
              line_width=1.5)
    box = BoxAnnotation(top=5, bottom=2, fill_alpha=0.1, fill_color='green')
              
    fig.add_layout(span)
    fig.add_layout(box)

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

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


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

curdoc().add_root(layout)

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions