Unexpected behaviour with gridplot and layout

Hello,

I am trying to understand gridplots and layouts. My starting point is code from the webpage:

‘’’
Code from Creating layouts — Bokeh 2.4.2 Documentation
‘’’

from bokeh.io import output_server, show
from bokeh.layouts import gridplot, layout
from bokeh.palettes import Viridis3
from bokeh.plotting import figure
import subprocess
import time

if name == ‘main’:
args = [‘python’, ‘-m’, ‘bokeh’, ‘serve’]
p = subprocess.Popen(args)
time.sleep(1)
output_server(session_id=‘test’, autopush = True)

x = list(range(11))
y0 = x
y1 = [10 - i for i in x]
y2 = [abs(i - 5) for i in x]

# create three plots
p1 = figure(width=250, plot_height=250, title=None)
p1.circle(x, y0, size=10, color=Viridis3[0])
p2 = figure(width=250, height=250, title=None)
p2.triangle(x, y1, size=10, color=Viridis3[1])
p3 = figure(width=250, height=250, title=None)
p3.square(x, y2, size=10, color=Viridis3[2])

# make a grid
grid = gridplot([[p1, p2], [None, p3]])

testlayout = layout([[p1, p2, p3]], sizing_mode=‘stretch_both’)

# show the results
show(grid)

show(testlayout)

``

This works as shown on the webpage:

When I add an (unused) layout,

# make a grid
grid = gridplot([[p1, p2], [None, p3]])
testlayout = layout([[p1, p2, p3]], sizing_mode='stretch_both')

# show the results
show(grid)

show(testlayout)

``

``

``

the output changes to (screenshot):

When I use the save-button I get three images, although only one is visible in the webpage.

Console output:

2016-10-26 21:02:09,054 Starting Bokeh server version 0.12.2

2016-10-26 21:02:09,061 Starting Bokeh server on port 5006 with applications at paths [’/’]

2016-10-26 21:02:09,061 Starting Bokeh server with process id: 736

2016-10-26 21:02:09,109 WebSocket connection opened

2016-10-26 21:02:09,110 ServerConnection created

2016-10-26 21:02:09,260 WebSocket connection closed: code=1000, reason=‘closed’

INFO:bokeh.client._connection:Connection closed by server

2016-10-26 21:02:09,520 200 GET /?bokeh-session-id=test (::1) 13.01ms

2016-10-26 21:02:10,058 WebSocket connection opened

2016-10-26 21:02:10,059 ServerConnection created

2016-10-26 21:02:10,648 error handling message Message ‘PATCH-DOC’ (revision 1): DeserializationError('Int exp

ected Integral, got 1.4210854715202004e-14’,)

Last version, only layout

make a grid

grid = gridplot([[p1, p2], [None, p3]])

testlayout = layout([[p1, p2, p3]], sizing_mode=‘stretch_both’)

show the results

show(grid)

show(testlayout

``

is working as expected:

Is there a specific reason, why gridplot can not be mixed with an layout? Even if the layout variable is not used at all?

Thanks

Daniel

Hi,

···

On Wed, Oct 26, 2016 at 9:21 PM, ‘Daniel Krause’ via Bokeh Discussion - Public [email protected] wrote:

Hello,

I am trying to understand gridplots and layouts. My starting point is code from the webpage:

‘’’
Code from http://bokeh.pydata.org/en/latest/docs/user_guide/layout.html
‘’’

from bokeh.io import output_server, show
from bokeh.layouts import gridplot, layout
from bokeh.palettes import Viridis3
from bokeh.plotting import figure
import subprocess
import time

if name == ‘main’:
args = [‘python’, ‘-m’, ‘bokeh’, ‘serve’]
p = subprocess.Popen(args)
time.sleep(1)
output_server(session_id=‘test’, autopush = True)

x = list(range(11))
y0 = x
y1 = [10 - i for i in x]
y2 = [abs(i - 5) for i in x]

# create three plots
p1 = figure(width=250, plot_height=250, title=None)
p1.circle(x, y0, size=10, color=Viridis3[0])
p2 = figure(width=250, height=250, title=None)
p2.triangle(x, y1, size=10, color=Viridis3[1])
p3 = figure(width=250, height=250, title=None)
p3.square(x, y2, size=10, color=Viridis3[2])

# make a grid
grid = gridplot([[p1, p2], [None, p3]])

testlayout = layout([[p1, p2, p3]], sizing_mode=‘stretch_both’)

# show the results
show(grid)

show(testlayout)

``

This works as shown on the webpage:

When I add an (unused) layout,

# make a grid
grid = gridplot([[p1, p2], [None, p3]])
testlayout = layout([[p1, p2, p3]], sizing_mode='stretch_both')

# show the results
show(grid)

show(testlayout)

``

``

``

the output changes to (screenshot):

When I use the save-button I get three images, although only one is visible in the webpage.

Console output:

2016-10-26 21:02:09,054 Starting Bokeh server version 0.12.2

2016-10-26 21:02:09,061 Starting Bokeh server on port 5006 with applications at paths [‘/’]

2016-10-26 21:02:09,061 Starting Bokeh server with process id: 736

2016-10-26 21:02:09,109 WebSocket connection opened

2016-10-26 21:02:09,110 ServerConnection created

2016-10-26 21:02:09,260 WebSocket connection closed: code=1000, reason=‘closed’

INFO:bokeh.client._connection:Connection closed by server

2016-10-26 21:02:09,520 200 GET /?bokeh-session-id=test (::1) 13.01ms

2016-10-26 21:02:10,058 WebSocket connection opened

2016-10-26 21:02:10,059 ServerConnection created

2016-10-26 21:02:10,648 error handling message Message ‘PATCH-DOC’ (revision 1): DeserializationError('Int exp

ected Integral, got 1.4210854715202004e-14’,)

Given the above error message, I think that the behavior you experience isn’t a problem with layout, but some internal plumbing, most likely due to using output_server(), which is broken and has been deprecated. If you just want to play with layouts, I suggest using the most recent version of this example, which uses output_file() instead.

Mateusz

Last version, only layout

make a grid

grid = gridplot([[p1, p2], [None, p3]])

testlayout = layout([[p1, p2, p3]], sizing_mode=‘stretch_both’)

show the results

show(grid)

show(testlayout

``

is working as expected:

Is there a specific reason, why gridplot can not be mixed with an layout? Even if the layout variable is not used at all?

Thanks

Daniel

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/15778262-7821-4d8d-8594-a649ddd18a7b%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Yes, I noticed the first error message as well.
In the meantime I changed the imports to

from bokeh.client import push_session
from bokeh.layouts import gridplot, layout
from bokeh.palettes import Viridis3
from bokeh.plotting import figure, curdoc
import subprocess
import time

``

``

and the code with grid and layout as follows

# make a grid
grid = gridplot([[p1, p2], [None, p3]])
testlayout = layout([[p1, p2, p3]], sizing_mode='stretch_both')

# show the results
session = push_session(curdoc())
session.show(grid) # open the document in a browser

show(testlayout)

``

The result did not change, the behaviour stays the same.

But thanks for idea,

Daniel

···

Am Mittwoch, 26. Oktober 2016 22:11:20 UTC+2 schrieb mateusz.paprocki:

Hi,

On Wed, Oct 26, 2016 at 9:21 PM, ‘Daniel Krause’ via Bokeh Discussion - Public [email protected] wrote:

Hello,

I am trying to understand gridplots and layouts. My starting point is code from the webpage:

‘’’
Code from http://bokeh.pydata.org/en/latest/docs/user_guide/layout.html
‘’’

from bokeh.io import output_server, show
from bokeh.layouts import gridplot, layout
from bokeh.palettes import Viridis3
from bokeh.plotting import figure
import subprocess
import time

if name == ‘main’:
args = [‘python’, ‘-m’, ‘bokeh’, ‘serve’]
p = subprocess.Popen(args)
time.sleep(1)
output_server(session_id=‘test’, autopush = True)

x = list(range(11))
y0 = x
y1 = [10 - i for i in x]
y2 = [abs(i - 5) for i in x]

# create three plots
p1 = figure(width=250, plot_height=250, title=None)
p1.circle(x, y0, size=10, color=Viridis3[0])
p2 = figure(width=250, height=250, title=None)
p2.triangle(x, y1, size=10, color=Viridis3[1])
p3 = figure(width=250, height=250, title=None)
p3.square(x, y2, size=10, color=Viridis3[2])

# make a grid
grid = gridplot([[p1, p2], [None, p3]])

testlayout = layout([[p1, p2, p3]], sizing_mode=‘stretch_both’)

# show the results
show(grid)

show(testlayout)

``

This works as shown on the webpage:

When I add an (unused) layout,

# make a grid
grid = gridplot([[p1, p2], [None, p3]])
testlayout = layout([[p1, p2, p3]], sizing_mode='stretch_both')

# show the results
show(grid)

show(testlayout)

``

``

``

the output changes to (screenshot):

When I use the save-button I get three images, although only one is visible in the webpage.

Console output:

2016-10-26 21:02:09,054 Starting Bokeh server version 0.12.2

2016-10-26 21:02:09,061 Starting Bokeh server on port 5006 with applications at paths [‘/’]

2016-10-26 21:02:09,061 Starting Bokeh server with process id: 736

2016-10-26 21:02:09,109 WebSocket connection opened

2016-10-26 21:02:09,110 ServerConnection created

2016-10-26 21:02:09,260 WebSocket connection closed: code=1000, reason=‘closed’

INFO:bokeh.client._connection:Connection closed by server

2016-10-26 21:02:09,520 200 GET /?bokeh-session-id=test (::1) 13.01ms

2016-10-26 21:02:10,058 WebSocket connection opened

2016-10-26 21:02:10,059 ServerConnection created

2016-10-26 21:02:10,648 error handling message Message ‘PATCH-DOC’ (revision 1): DeserializationError('Int exp

ected Integral, got 1.4210854715202004e-14’,)

Given the above error message, I think that the behavior you experience isn’t a problem with layout, but some internal plumbing, most likely due to using output_server(), which is broken and has been deprecated. If you just want to play with layouts, I suggest using the most recent version of this example, which uses output_file() instead.

Mateusz

Last version, only layout

make a grid

grid = gridplot([[p1, p2], [None, p3]])

testlayout = layout([[p1, p2, p3]], sizing_mode=‘stretch_both’)

show the results

show(grid)

show(testlayout

``

is working as expected:

Is there a specific reason, why gridplot can not be mixed with an layout? Even if the layout variable is not used at all?

Thanks

Daniel

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/15778262-7821-4d8d-8594-a649ddd18a7b%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Sorry, my last message was not complete.
I updated to bokeh 0.12.3. In the console output appeared than an additional message stating the used output_server is deprecated. That was the reason why I changed the code.

As for the

error handling message Message ‘PATCH-DOC’ (revision 1): DeserializationError('Int exp

ected Integral, got 1.4210854715202004e-14’,)

``

I have no idea what that could mean.

Daniel

···

Am Mittwoch, 26. Oktober 2016 22:20:15 UTC+2 schrieb Daniel Krause:

Yes, I noticed the first error message as well.
In the meantime I changed the imports to

from bokeh.client import push_session
from bokeh.layouts import gridplot, layout
from bokeh.palettes import Viridis3
from bokeh.plotting import figure, curdoc
import subprocess
import time

``

``

and the code with grid and layout as follows

# make a grid
grid = gridplot([[p1, p2], [None, p3]])
testlayout = layout([[p1, p2, p3]], sizing_mode='stretch_both')

# show the results
session = push_session(curdoc())
session.show(grid) # open the document in a browser

show(testlayout)

``

The result did not change, the behaviour stays the same.

But thanks for idea,

Daniel

Am Mittwoch, 26. Oktober 2016 22:11:20 UTC+2 schrieb mateusz.paprocki:

Hi,

On Wed, Oct 26, 2016 at 9:21 PM, ‘Daniel Krause’ via Bokeh Discussion - Public [email protected] wrote:

Hello,

I am trying to understand gridplots and layouts. My starting point is code from the webpage:

‘’’
Code from http://bokeh.pydata.org/en/latest/docs/user_guide/layout.html
‘’’

from bokeh.io import output_server, show
from bokeh.layouts import gridplot, layout
from bokeh.palettes import Viridis3
from bokeh.plotting import figure
import subprocess
import time

if name == ‘main’:
args = [‘python’, ‘-m’, ‘bokeh’, ‘serve’]
p = subprocess.Popen(args)
time.sleep(1)
output_server(session_id=‘test’, autopush = True)

x = list(range(11))
y0 = x
y1 = [10 - i for i in x]
y2 = [abs(i - 5) for i in x]

# create three plots
p1 = figure(width=250, plot_height=250, title=None)
p1.circle(x, y0, size=10, color=Viridis3[0])
p2 = figure(width=250, height=250, title=None)
p2.triangle(x, y1, size=10, color=Viridis3[1])
p3 = figure(width=250, height=250, title=None)
p3.square(x, y2, size=10, color=Viridis3[2])

# make a grid
grid = gridplot([[p1, p2], [None, p3]])

testlayout = layout([[p1, p2, p3]], sizing_mode=‘stretch_both’)

# show the results
show(grid)

show(testlayout)

``

This works as shown on the webpage:

When I add an (unused) layout,

# make a grid
grid = gridplot([[p1, p2], [None, p3]])
testlayout = layout([[p1, p2, p3]], sizing_mode='stretch_both')

# show the results
show(grid)

show(testlayout)

``

``

``

the output changes to (screenshot):

When I use the save-button I get three images, although only one is visible in the webpage.

Console output:

2016-10-26 21:02:09,054 Starting Bokeh server version 0.12.2

2016-10-26 21:02:09,061 Starting Bokeh server on port 5006 with applications at paths [‘/’]

2016-10-26 21:02:09,061 Starting Bokeh server with process id: 736

2016-10-26 21:02:09,109 WebSocket connection opened

2016-10-26 21:02:09,110 ServerConnection created

2016-10-26 21:02:09,260 WebSocket connection closed: code=1000, reason=‘closed’

INFO:bokeh.client._connection:Connection closed by server

2016-10-26 21:02:09,520 200 GET /?bokeh-session-id=test (::1) 13.01ms

2016-10-26 21:02:10,058 WebSocket connection opened

2016-10-26 21:02:10,059 ServerConnection created

2016-10-26 21:02:10,648 error handling message Message ‘PATCH-DOC’ (revision 1): DeserializationError('Int exp

ected Integral, got 1.4210854715202004e-14’,)

Given the above error message, I think that the behavior you experience isn’t a problem with layout, but some internal plumbing, most likely due to using output_server(), which is broken and has been deprecated. If you just want to play with layouts, I suggest using the most recent version of this example, which uses output_file() instead.

Mateusz

Last version, only layout

make a grid

grid = gridplot([[p1, p2], [None, p3]])

testlayout = layout([[p1, p2, p3]], sizing_mode=‘stretch_both’)

show the results

show(grid)

show(testlayout

``

is working as expected:

Is there a specific reason, why gridplot can not be mixed with an layout? Even if the layout variable is not used at all?

Thanks

Daniel

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/15778262-7821-4d8d-8594-a649ddd18a7b%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

I lost the thread of this, but here's a complete code sample that works in a couple of configurations with some comments made inline:

···

-----

from bokeh.client import push_session
from bokeh.layouts import gridplot, layout
from bokeh.palettes import Viridis3
from bokeh.plotting import figure, curdoc
import subprocess
import time

if __name__ == '__main__':
    args = ['python', '-m', 'bokeh', 'serve']
    p = subprocess.Popen(args)

    # had to increase, bokeh serve takes more time to start
    # probably better to coordinate externally, or find a way to wait
    # until the server start can be confirmed as completed
    time.sleep(3)

    x = list(range(11))
    y0 = x
    y1 = [10 - i for i in x]
    y2 = [abs(i - 5) for i in x]

    # create three plots
    p1 = figure(width=250, plot_height=250, title=None)
    p1.circle(x, y0, size=10, color=Viridis3[0])
    p2 = figure(width=250, height=250, title=None)
    p2.triangle(x, y1, size=10, color=Viridis3[1])
    p3 = figure(width=250, height=250, title=None)
    p3.square(x, y2, size=10, color=Viridis3[2])

     # either one or the other of these works -- but not BOTH at once
     # cannot re-use same plot twice in a Bokeh app
    #layout = gridplot([[p1, p2], [None, p3]])
    layout = layout([[p1, p2, p3]], sizing_mode='stretch_both')

    # show the results
    session = push_session(curdoc())
    session.show(layout) # open the document in a browser
    session.loop_until_closed()

Thanks again Bryan!

···

Am Mittwoch, 26. Oktober 2016 21:21:04 UTC+2 schrieb Daniel Krause:

Hello,

I am trying to understand gridplots and layouts. My starting point is code from the webpage:

‘’’
Code from http://bokeh.pydata.org/en/latest/docs/user_guide/layout.html
‘’’

from bokeh.io import output_server, show
from bokeh.layouts import gridplot, layout
from bokeh.palettes import Viridis3
from bokeh.plotting import figure
import subprocess
import time

if name == ‘main’:
args = [‘python’, ‘-m’, ‘bokeh’, ‘serve’]
p = subprocess.Popen(args)
time.sleep(1)
output_server(session_id=‘test’, autopush = True)

x = list(range(11))
y0 = x
y1 = [10 - i for i in x]
y2 = [abs(i - 5) for i in x]

# create three plots
p1 = figure(width=250, plot_height=250, title=None)
p1.circle(x, y0, size=10, color=Viridis3[0])
p2 = figure(width=250, height=250, title=None)
p2.triangle(x, y1, size=10, color=Viridis3[1])
p3 = figure(width=250, height=250, title=None)
p3.square(x, y2, size=10, color=Viridis3[2])

# make a grid
grid = gridplot([[p1, p2], [None, p3]])

testlayout = layout([[p1, p2, p3]], sizing_mode=‘stretch_both’)

# show the results
show(grid)

show(testlayout)

``

This works as shown on the webpage:

When I add an (unused) layout,

# make a grid
grid = gridplot([[p1, p2], [None, p3]])
testlayout = layout([[p1, p2, p3]], sizing_mode='stretch_both')

# show the results
show(grid)

show(testlayout)

``

``

``

the output changes to (screenshot):

When I use the save-button I get three images, although only one is visible in the webpage.

Console output:

2016-10-26 21:02:09,054 Starting Bokeh server version 0.12.2

2016-10-26 21:02:09,061 Starting Bokeh server on port 5006 with applications at paths [‘/’]

2016-10-26 21:02:09,061 Starting Bokeh server with process id: 736

2016-10-26 21:02:09,109 WebSocket connection opened

2016-10-26 21:02:09,110 ServerConnection created

2016-10-26 21:02:09,260 WebSocket connection closed: code=1000, reason=‘closed’

INFO:bokeh.client._connection:Connection closed by server

2016-10-26 21:02:09,520 200 GET /?bokeh-session-id=test (::1) 13.01ms

2016-10-26 21:02:10,058 WebSocket connection opened

2016-10-26 21:02:10,059 ServerConnection created

2016-10-26 21:02:10,648 error handling message Message ‘PATCH-DOC’ (revision 1): DeserializationError('Int exp

ected Integral, got 1.4210854715202004e-14’,)

Last version, only layout

make a grid

grid = gridplot([[p1, p2], [None, p3]])

testlayout = layout([[p1, p2, p3]], sizing_mode=‘stretch_both’)

show the results

show(grid)

show(testlayout

``

is working as expected:

Is there a specific reason, why gridplot can not be mixed with an layout? Even if the layout variable is not used at all?

Thanks

Daniel