diff --git a/holoviews/core/layout.py b/holoviews/core/layout.py index 4219768c84..592ec71a41 100644 --- a/holoviews/core/layout.py +++ b/holoviews/core/layout.py @@ -62,8 +62,8 @@ class Empty(Dimensioned, Composable): group = param.String(default='Empty') - def __init__(self): - super().__init__(None) + def __init__(self, **params): + super().__init__(None, **params) diff --git a/holoviews/ipython/display_hooks.py b/holoviews/ipython/display_hooks.py index 283f8f6f23..b0e6ff3c20 100644 --- a/holoviews/ipython/display_hooks.py +++ b/holoviews/ipython/display_hooks.py @@ -15,7 +15,7 @@ AbbreviatedException) from ..core import ( ViewableElement, HoloMap, AdjointLayout, NdLayout, GridSpace, - Layout, CompositeOverlay, DynamicMap, Dimensioned + Layout, CompositeOverlay, DynamicMap, Dimensioned, Empty ) from ..core.traversal import unique_dimkeys from ..core.io import FileArchive @@ -178,7 +178,7 @@ def element_display(element, max_frames): info = process_object(element) if info: display(HTML(info)) - return + return None backend = Store.current_backend if type(element) not in Store.registry[backend]: @@ -253,6 +253,8 @@ def display(obj, raw_output=False, **kwargs): output = map_display(obj) elif isinstance(obj, Plot): output = render(obj) + elif isinstance(obj, Empty): + output = ({}, {}) else: output = obj raw = kwargs.pop('raw', False) diff --git a/holoviews/plotting/plot.py b/holoviews/plotting/plot.py index e1cd6a588b..e57e9a7637 100644 --- a/holoviews/plotting/plot.py +++ b/holoviews/plotting/plot.py @@ -138,7 +138,7 @@ def pane(self, pane): for plot in self.subplots.values(): if plot is not None: plot.pane = pane - if not plot.root: + if plot is None or not plot.root: continue for cb in getattr(plot, 'callbacks', []): if hasattr(pane, '_on_error') and getattr(cb, 'comm', None): diff --git a/holoviews/tests/plotting/bokeh/test_layoutplot.py b/holoviews/tests/plotting/bokeh/test_layoutplot.py index 83cdb5c749..1602a67a50 100644 --- a/holoviews/tests/plotting/bokeh/test_layoutplot.py +++ b/holoviews/tests/plotting/bokeh/test_layoutplot.py @@ -228,6 +228,14 @@ def test_empty_adjoint_plot(self): self.assertEqual(s1.height, 0) self.assertEqual(f1.plot_height, f2.plot_height) + def test_empty_adjoint_plot_with_renderer(self): + # https://github.com/holoviz/holoviews/pull/5584 + scatter = Scatter(range(10)) + adjoin_layout_plot = scatter << Empty() << scatter.hist(adjoin=False) + + # To render the plot + bokeh_renderer(adjoin_layout_plot) + def test_layout_plot_with_adjoints(self): layout = (Curve([]) + Curve([]).hist()).cols(1) plot = bokeh_renderer.get_plot(layout)