Hi,
I am trying to get my layout to be responsive, but I am having a few problems.
This is the layout I’d like to achieve: link(getting access errors trying to upload it here)
I spend the better half of the day trying a bunch of possibilities, this is what I got.
It renders just fine but is not responsive like I want it to be.
code:
from bokeh.io import show
from bokeh.layouts import row, column, gridplot
from bokeh.models import DataRange1d, ColumnDataSource, ColorBar, LinearColorMapper, Slider, PreText, Button, Spacer
from bokeh.plotting import figure
import numpy as np
from bokeh.palettes import grey
##############
sx = 180
sy = 80
image_data = np.random.rand(sy, sx)
x_range = DataRange1d(start=0, end=sx, bounds=(0, sx), min_interval=1, range_padding=0)
y_range = DataRange1d(start=0, end=sy, bounds=(0, sy), min_interval=1, range_padding=0)
plot_width = 1000
plot_height = int(plot_width * sy / sx)
color_mapper = LinearColorMapper(palette=grey(6), low=np.min(image_data), high=np.max(image_data))
plot = figure(title="image_1", tools=[],
x_range=x_range, y_range=y_range, plot_width=plot_width, plot_height=plot_height, toolbar_location="above",
sizing_mode="scale_both")
source = ColumnDataSource(data=dict(image=[image_data]))
img = plot.image(source=source, x=0, y=0,
dw=sx, dh=sy,
color_mapper=color_mapper)
dummy = figure(height=plot.plot_height, width=60, toolbar_location=None, outline_line_color=None)
color_bar = ColorBar(color_mapper=color_mapper, label_standoff=12)
dummy.add_layout(color_bar, 'right')
image_row = row(plot, dummy)
################
offset = Slider(title="offset", value=0.0, start=-5.0, end=5.0, step=0.1, max_width=150)
amplitude = Slider(title="amplitude", value=1.0, start=-5.0, end=5.0, step=0.1, max_width=150)
phase = Slider(title="phase", value=0.0, start=0.0, end=2*np.pi, max_width=150)
freq = Slider(title="frequency", value=1.0, start=0.1, end=5.1, step=0.1, max_width=150)
slider_column = column(offset, amplitude, phase, freq)
#################
some_text = PreText(text="""Your text is initialized with the 'text' argument.
The remaining Paragraph arguments are 'width' and 'height'. For this example,
those values are 500 and 100, respectively.""", max_width=300)
##################
long_slider = Slider(title="long", value=0, start=0, end=100, step=1, sizing_mode='stretch_width')
play_button = Button(label='►',aspect_ratio=1, align="center")
long_slider2 = Slider(title="long2", value=0, start=0, end=100, step=1, sizing_mode='stretch_width')
play_button2 = Button(label='►',aspect_ratio=1, align="center")
long_sliders = column(row(long_slider, play_button), row(long_slider2, play_button2), sizing_mode='stretch_width')
####################
grid = gridplot([[slider_column, column(image_row, long_sliders), column(Spacer(height=300), some_text)],
],)
show(grid)