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

Fix Grid level alignment #3957

Merged
merged 2 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions examples/user_guide/Plotting_with_Bokeh.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand Down
4 changes: 4 additions & 0 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.""")

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions holoviews/plotting/bokeh/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down