diff --git a/examples/user_guide/Plotting_with_Bokeh.ipynb b/examples/user_guide/Plotting_with_Bokeh.ipynb index 5f936c2a42..82a7f5245e 100644 --- a/examples/user_guide/Plotting_with_Bokeh.ipynb +++ b/examples/user_guide/Plotting_with_Bokeh.ipynb @@ -282,6 +282,50 @@ "img.opts(data_aspect=0.5, responsive=True, title='scale both')" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Alignment\n", + "\n", + "The aligment of a plot in a row or column can be controlled using ``align`` option. It controls both the vertical alignment in a row and the horizontal alignment in a column and can be set to one of `'start'`, `'center'` or `'end'` (where `'start'` is the default)." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Vertical" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "points = hv.Points(data).opts(axiswise=True)\n", + "img = hv.Image((xs, ys, xs[:, np.newaxis]*np.sin(ys*4)))\n", + "\n", + "img + points.opts(height=200, align='end')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Horizontal" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "(img.opts(axiswise=True, width=200, align='center') + points).cols(1)" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/holoviews/plotting/bokeh/element.py b/holoviews/plotting/bokeh/element.py index 945b3cb986..841efde8c3 100644 --- a/holoviews/plotting/bokeh/element.py +++ b/holoviews/plotting/bokeh/element.py @@ -51,6 +51,9 @@ class ElementPlot(BokehPlot, GenericElementPlot): both 'pan' and 'box_zoom' are drag tools, so if both are listed only the last one will be active.""") + align = param.ObjectSelector(default=None, objects=['start', 'center', 'end'], doc=""" + Alignment (vertical or horizontal) of the plot in a layout.""") + border = param.Number(default=10, doc=""" Minimum border around plot.""") @@ -503,6 +506,7 @@ def _plot_properties(self, key, element): self.callbacks.append(PlotSizeCallback(self, [stream], None)) plot_props = { + 'align': self.align, 'margin': self.margin, 'max_width': self.max_width, 'max_height': self.max_height, diff --git a/holoviews/plotting/bokeh/plot.py b/holoviews/plotting/bokeh/plot.py index 8ea02dd1d2..726483df27 100644 --- a/holoviews/plotting/bokeh/plot.py +++ b/holoviews/plotting/bokeh/plot.py @@ -500,6 +500,8 @@ def _create_subplots(self, layout, ranges): kwargs['frame_width'] = width if height is not None: kwargs['frame_height'] = height + if c == 0: + kwargs['align'] = 'end' if c == 0 and r != 0: kwargs['xaxis'] = None if c != 0 and r == 0: