I have two plots: p as the main plot, and p_legend as a fixed sized plot acting as a legend for p. I set their corresponding width/height/sizing and put them in a gridplot, but find it very difficult to get the desired sizing behavior.
from bokeh.plotting import figure, show, gridplot, output_file, output_notebook
# output_notebook()
output_file('tmp.html')
p = figure(
width=600,
height=200,
min_height=200,
max_height=600,
width_policy='max',
height_policy='max',
tools='fullscreen',
)
p.line(x=[1, 2, 3], y=[1, 2, 3], color='red')
p.line(x=[1, 2, 3], y=[2, 3, 4], color='blue')
p_legend = figure(
width=300,
height=22,
min_height=22,
max_height=22,
# width_policy='fixed',
# height_policy='fixed',
sizing_mode='fixed',
x_range=(-1, 100),
y_range=(-1, 2),
tools='',
)
p_legend.axis.visible = False
p_legend.grid.visible = False
p_legend.quad(top=[1], bottom=[0], left=[0], right=[1])
show(gridplot(children=[[p_legend], [p]], sizing_mode='stretch_both'))
With sizing_mode='stretch_width'
for gridplot, it fits full width but it is on the top: can it be placed in the center?
With sizing_mode='stretch_both'
for gridplot, individual plots have their correct sizes, but they are separated: can they be attached together and also centered?
Thanks.