Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] figures collapse for different sizing_mode #13077

Open
muendlein opened this issue Apr 10, 2023 · 3 comments
Open

[BUG] figures collapse for different sizing_mode #13077

muendlein opened this issue Apr 10, 2023 · 3 comments

Comments

@muendlein
Copy link
Contributor

Software versions

Python version : 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)]
IPython version : (not installed)
Tornado version : 6.2
Bokeh version : 2.4.3/3.1.0
node.js version : v16.15.0
npm version : 8.5.5
Operating system : Windows-10-10.0.19045-SP0

Browser name and version

No response

Jupyter notebook / Jupyter Lab version

No response

Expected behavior

Using stretch_width or scale_width should not collapse figures.

Observed behavior

Starting with version 3.0 (also present in the latest version) figures may collapse if stretch_width or scale_width are used for the sizing_mode. Note: This can also be observed in the documentation: https://docs.bokeh.org/en/latest/docs/user_guide/basic/layouts.html#multiple-objects
In case of stretch_width the collapsed layout also stretches in the height direction which is rather weird.

2.4.3 Scale width
bokeh_scale_width_2_4_3

2.4.3 Stretch width
bokeh_stretch_width_2_4_3

3.1.0 Scale width
bokeh_scale_width_3_1_0

3.1.0 Stretch width
bokeh_stretch_width_3_1_0

Example code

import numpy as np

from bokeh.io import curdoc
from bokeh.layouts import column, row
from bokeh.models import ColumnDataSource, Slider, TextInput
from bokeh.plotting import figure


# Set up plot
plot = figure(title="my sine wave",
              tools="crosshair,pan,reset,save,wheel_zoom",
              x_range=[0, 4*np.pi], y_range=[-2.5, 2.5], sizing_mode="stretch_width")

# Set up widgets
text = TextInput(title="title", value='my sine wave')
offset = Slider(title="offset", value=0.0, start=-5.0, end=5.0, step=0.1)
amplitude = Slider(title="amplitude", value=1.0, start=-5.0, end=5.0, step=0.1)
phase = Slider(title="phase", value=0.0, start=0.0, end=2*np.pi)
freq = Slider(title="frequency", value=1.0, start=0.1, end=5.1, step=0.1)


# Set up layouts and add to document
inputs = column(text, offset, amplitude, phase, freq)

curdoc().add_root(row(inputs, plot))
curdoc().title = "Sliders"

Stack traceback or browser console output

No response

Screenshots

No response

@bryevdv
Copy link
Member

bryevdv commented Apr 10, 2023

cc @mattpap

@orena1
Copy link
Contributor

orena1 commented Apr 17, 2023

@mattpap
Copy link
Contributor

mattpap commented May 29, 2023

curdoc().add_root(row(inputs, plot))

This should include sizing_mode as well:

curdoc().add_root(row(inputs, plot, sizing_mode="stretch_width"))

The general advice is to make sure that sizing modes are assigned top down. One can use new "inherit" sizing mode in inner layouts to inherit the sizing mode from its parent. However, we will probably consider this a regression. Previously layout would infer from its children whether it should expand or not. The new layout introduced in bokeh 3.0 doesn't do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants