Dynamically adding new plots to layout

Hi folks,

I’m trying to build up an application that requires the user to be able to add new plots to the layout, according to various settings controlled by Bokehs widgets. I have been able to achieve this, but the layout keeps getting messed up when plots are added in a certain sequence to the layout. I’ve tried to produce a simplified version of the code to reproduce the problem. You can access that here.

To reproduce the bad behaviour that I am observing:

  1. run the script with bokeh server

  2. press the ‘add below’ button and observe the new plot added below the first, then

  3. press the ‘add across’ button and observe the new plot added to the right of the first.

The second plot, which had been added when the ‘add below’ button was pressed, becomes squashed to a height of 0. I’ve tried all kinds of thing playing around with the heights of the row and column objects, and tried switching to a layout maintained with grid plot, but have always run into the same issue.

Has anyone ever seen this before? Do you have suggestions on what I might be doing wrong, and/or how I can fix this problem?

Thanks,

Toby

Bokeh version: 0.12.3

Python version: 3.5.1 (same behaviour observed on 2.7.10)

OS: Mac OSX 10.11.6 (El Capitan)

Browser: Safari 10.0.1

Ah, after browsing around the GH Issues, I found #4764, which looks like an earlier report of the same problem.

I guess this hasn’t been fixed yet, but it’s reassuring to know that it might not just be something that I’m doing wrong.

I will link to this in a comment on the Issue, in case it is helpful in the bug-fixing process.

···

On Thursday, November 24, 2016 at 4:07:29 PM UTC+1, Toby Hodges wrote:

Hi folks,

I’m trying to build up an application that requires the user to be able to add new plots to the layout, according to various settings controlled by Bokehs widgets. I have been able to achieve this, but the layout keeps getting messed up when plots are added in a certain sequence to the layout. I’ve tried to produce a simplified version of the code to reproduce the problem. You can access that here.

To reproduce the bad behaviour that I am observing:

  1. run the script with bokeh server
  1. press the ‘add below’ button and observe the new plot added below the first, then
  1. press the ‘add across’ button and observe the new plot added to the right of the first.

The second plot, which had been added when the ‘add below’ button was pressed, becomes squashed to a height of 0. I’ve tried all kinds of thing playing around with the heights of the row and column objects, and tried switching to a layout maintained with grid plot, but have always run into the same issue.

Has anyone ever seen this before? Do you have suggestions on what I might be doing wrong, and/or how I can fix this problem?

Thanks,

Toby

Bokeh version: 0.12.3

Python version: 3.5.1 (same behaviour observed on 2.7.10)

OS: Mac OSX 10.11.6 (El Capitan)

Browser: Safari 10.0.1

Hi Toby,
I have the same problem when trying to update more than one bokeh chart via call backs on a bokeh server. Unfortunatelly I do not have a solution and I am aware that the community is working on it.
However, I noticed that, at least with my code, charts are updated as expected in Internet Explorer (yes, I’m running Windows) after the first call back. But at the second call back it stops updating and I see the error you mentioned. Did you try differen browsers?

···

On Thursday, 24 November 2016 15:07:29 UTC, Toby Hodges wrote:

Hi folks,

I’m trying to build up an application that requires the user to be able to add new plots to the layout, according to various settings controlled by Bokehs widgets. I have been able to achieve this, but the layout keeps getting messed up when plots are added in a certain sequence to the layout. I’ve tried to produce a simplified version of the code to reproduce the problem. You can access that here.

To reproduce the bad behaviour that I am observing:

  1. run the script with bokeh server
  1. press the ‘add below’ button and observe the new plot added below the first, then
  1. press the ‘add across’ button and observe the new plot added to the right of the first.

The second plot, which had been added when the ‘add below’ button was pressed, becomes squashed to a height of 0. I’ve tried all kinds of thing playing around with the heights of the row and column objects, and tried switching to a layout maintained with grid plot, but have always run into the same issue.

Has anyone ever seen this before? Do you have suggestions on what I might be doing wrong, and/or how I can fix this problem?

Thanks,

Toby

Bokeh version: 0.12.3

Python version: 3.5.1 (same behaviour observed on 2.7.10)

OS: Mac OSX 10.11.6 (El Capitan)

Browser: Safari 10.0.1

from numpy import random

from bokeh.plotting import figure, curdoc

from bokeh.layouts import row, widgetbox

from bokeh.models.widgets import Button

from bokeh.client import push_session

def draw_plot(data):

plot = figure(width = 550, height = 350)

plot.circle(data, data)

return plot

def add_to_axis(axis):

if axis == 'y': layout.children.append(draw_plot(data))

elif axis == 'x': layout.children.append(row(draw_plot(data)))

def add_below(): add_to_axis(‘x’)

def add_across(): add_to_axis(‘y’)

data = [random.random() for i in range(10)]

add_below_button = Button(label = ‘add below’, width = 150)

add_across_button = Button(label = ‘add across’, width = 150)

add_below_button.on_click(add_below)

add_across_button.on_click(add_across)

curdoc().add_root(widgetbox([add_below_button, add_across_button], width = 200))

layout = row(width = 10000, height = 10000)

session = push_session(curdoc())

session.show(layout)

session.loop_until_closed()

``

···

On Thursday, November 24, 2016 at 4:07:29 PM UTC+1, Toby Hodges wrote:

Hi folks,

I’m trying to build up an application that requires the user to be able to add new plots to the layout, according to various settings controlled by Bokehs widgets. I have been able to achieve this, but the layout keeps getting messed up when plots are added in a certain sequence to the layout. I’ve tried to produce a simplified version of the code to reproduce the problem. You can access that here.

To reproduce the bad behaviour that I am observing:

  1. run the script with bokeh server
  1. press the ‘add below’ button and observe the new plot added below the first, then
  1. press the ‘add across’ button and observe the new plot added to the right of the first.

The second plot, which had been added when the ‘add below’ button was pressed, becomes squashed to a height of 0. I’ve tried all kinds of thing playing around with the heights of the row and column objects, and tried switching to a layout maintained with grid plot, but have always run into the same issue.

Has anyone ever seen this before? Do you have suggestions on what I might be doing wrong, and/or how I can fix this problem?

Thanks,

Toby

Bokeh version: 0.12.3

Python version: 3.5.1 (same behaviour observed on 2.7.10)

OS: Mac OSX 10.11.6 (El Capitan)

Browser: Safari 10.0.1