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