I'm looking for a simple way to swap out figures inside a layout...basically hiding one figure and displaying another. Below I have an example of my intent. What Im seeing is that when a figure is dynamically added to a Column, its plot_height/plot_width is set to 0.
Example:
from bokeh.io import curdoc
from bokeh.plotting import Figure
from bokeh.models import Row, Column, Button
from random import randint
def _create_fig():
fig = Figure(plot_width=100, plot_height=100)
fig.circle(x=0, y=0)
return fig
def callback():
num = randint(0,9)
if num > 5:
fig1_col.children = [_create_fig()]
fig2_col.children = []
else:
fig2_col.children = [_create_fig()]
fig1_col.children = []
fig1 = _create_fig()
fig2 = _create_fig()
button = Button()
button.on_click(callback)
button_row = Row(children=[button])
fig1_col = Column(children=[fig1])
fig2_col = Column(children=[fig2])
fig_row = Row(children=[fig1_col, fig2_col])
layout = Column(children=[button_row, fig_row])
curdoc().add_root(layout)
I'm looking for a simple way to swap out figures inside a layout...basically hiding one figure and displaying another. Below I have an example of my intent. What Im seeing is that when a figure is dynamically added to a Column, its plot_height/plot_width is set to 0.
Example: