holoviews
holoviews copied to clipboard
data_aspect and responsive do not work together when data_aspect>1
ALL software version info
- HoloViews tried latest master and latest release
- Bokeh 2.4.2
Description of expected behavior and the observed behavior
data_aspect and responsive do not work together when data_aspect>1.
The width of the plot seems to get set to 0.
Complete, minimal, self-contained example code that reproduces the issue
Here I am plotting the figure twice, once with just HoloViews and once by first rendering and then calling bokeh.io.show
import holoviews as hv
import bokeh.io
hv.notebook_extension("bokeh")
i = 1 + 1e-3 # Change to just 1, and the problem is gone!
p = hv.Polygons({"x": [0, 1, 1, 0], "y": [0, 0, i, i]}).opts(
responsive=True, data_aspect=1, min_height=50
)
display(p) # shows messed-up figure
bokeh.io.show(hv.render(p, "bokeh")) # correctly shows figure
Stack traceback and/or browser JavaScript console output
Screenshots or screencasts of the bug in action
![image](https://user-images.githubusercontent.com/6897215/180275220-415a2030-831e-4b6f-a5ee-882ce40a7003.png)
TL:DR: This is properly a bokeh problem and has been fixed upstream.
So I can somewhat recreate this problem. I'm using bokeh
2.4.3 and the latest master of holoviews
. The difference is either that they both fail or both succeed.
With i = 1.001
HoloViews uses a different (older?) version of defining a plot's dimension and aspect properties. These properties are then converted to Bokeh definition with this function:
https://github.com/holoviz/holoviews/blob/67f1fcf35586fdd2e9d83786e3110f87310123dd/holoviews/plotting/bokeh/util.py#L185-L188
So comparing Bokeh properties for i = 1
and i = 1.001
,
Where the relevant properties are: min_height
, sizing_mode
, and aspect_ratio
. This can then be converted to bokeh only example:
from bokeh.plotting import figure, output_file, show
import bokeh.io
# instantiating the figure object
graph = figure(min_height=50, sizing_mode="scale_both", aspect_ratio=0.999)
# the points to be plotted
xs = [[[[0, 1, 1, 0]]]]
ys = [[[[0, 0, 1, 1]]]]
# plotting the graph
graph.multi_polygons(xs, ys)
# displaying the model
bokeh.io.show(graph)
This will fail for some combinations and not for other combinations:
Failure | Success |
---|---|
![]() |
![]() |
Luckily, this has been fixed by Bokeh. Running the example which failed on the latest dev release, we get:
Thanks a lot for your detailed answer @Hoxbro! Are you aware of which Bokeh issue/PR solved this problem?
No, the new version of Bokeh has an entirely new layout engine, which is properly what fixed it.
It could be a single PR that has fixed it, but I haven't looked.
@Hoxbro, is it already possible to use the new bokeh with HoloViews?
I have tried but there seems to be an incompatibility with panel.
Edit: I just found https://github.com/holoviz/panel/pull/3752
Running the current main of Panel and HoloViews with bokeh3.1.dev2, we get the following output
So soon you will be able to run this example without it collapsing :slightly_smiling_face:
That's great! I am looking forward to Bokeh 3 support 😄