Skip to content
Closed
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
55 changes: 54 additions & 1 deletion doc/ref/plotting_options/size_layout.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@
"(option-widget_location)=\n",
"## `widget_location`\n",
"\n",
"Control where widgets appear. Valid values are `'right'` (default), `'left'`, `'bottom'`, `'right'`, `'top'`, `'top_left'`, `'top_right'`, `'bottom_left'`, `'bottom_right'`, `'left_top'`, `'left_bottom'`, `'right_top'`, `'right_bottom'`.\n",
"Control where widgets appear. Valid values are `'right_top'` (default), `'left'`, `'bottom'`, `'right'`, `'top'`, `'top_left'`, `'top_right'`, `'bottom_left'`, `'bottom_right'`, `'left_top'`, `'left_bottom'`, `'right_top'`, `'right_bottom'`.\n",
"\n",
":::{important}\n",
"When this option is set the object returned is no longer a HoloViews object but a Panel layout. In the future we intend to address that, follow [this issue](https://github.com/holoviz/holoviews/issues/6590) for more information.\n",
Expand Down Expand Up @@ -404,6 +404,59 @@
")"
]
},
{
"cell_type": "markdown",
"id": "74bd136d-9cde-4cfb-9fbb-1c7f99c1dfb1",
"metadata": {},
"source": [
"(option-widgets)=\n",
"(option-widget_layout)=\n",
"(option-widget_type)=\n",
"## Customizing generated widgets\n",
"\n",
"Use `widgets` to map a `groupby` dimension to a Panel widget type or instance. The `widget_layout` option accepts a Panel layout type, such as `pn.Row` or `pn.Column`, and controls how multiple widgets are arranged. Set `widget_type='scrubber'` to replace the individual controls with one player that steps through every combination of grouped values.\n",
"\n",
"These options return a Panel layout rather than the underlying HoloViews object. A scrubber requires every grouped dimension to define a finite set of values."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0d95aa14-40b4-4ec4-8b60-0a6e3f2ea907",
"metadata": {},
"outputs": [],
"source": [
"import panel as pn\n",
"import hvplot.pandas # noqa\n",
"\n",
"df = hvplot.sampledata.penguins(\"pandas\")\n",
"\n",
"df.hvplot.scatter(\n",
" x='bill_length_mm', y='bill_depth_mm', frame_width=250,\n",
" groupby='species',\n",
" widgets={'species': pn.widgets.RadioButtonGroup},\n",
" widget_layout=pn.Row, widget_location='top',\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "97eb2f9a-1250-4d4b-94b7-84d8da385924",
"metadata": {},
"outputs": [],
"source": [
"import hvplot.pandas # noqa\n",
"\n",
"df = hvplot.sampledata.penguins(\"pandas\")\n",
"\n",
"df.hvplot.scatter(\n",
" x='bill_length_mm', y='bill_depth_mm', frame_width=250,\n",
" groupby=['species', 'island'],\n",
" widget_type='scrubber', widget_location='bottom',\n",
")"
]
},
{
"cell_type": "markdown",
"id": "9a7924e9-b9f9-4238-a4cf-e8449cedb8cb",
Expand Down
16 changes: 13 additions & 3 deletions hvplot/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,23 @@ class HoloViewsConverter:
width and height or width and aspect are set the plot is set
to a fixed size, ignoring any responsive option. Only supported by the
interactive plotting backends.
widget_location : str, optional
widget_location : str, default='right_top'
Specifies where to place widgets generated by options like ``groupby``.
Valid values are: ``'right'`` (default), ``'left'``, ``'bottom'``,
``'right'``, ``'top'``, ``'top_left'``, ``'top_right'``,
Valid values are: ``'left'``, ``'bottom'``, ``'right'``, ``'top'``,
``'top_left'``, ``'top_right'``,
``'bottom_left'``, ``'bottom_right'``, ``'left_top'``,
``'left_bottom'``, ``'right_top'``, ``'right_bottom'``.
Only applies if the plot generates widgets (e.g. via ``groupby``).
widget_layout : type, default=panel.WidgetBox
Panel layout type used to arrange generated widgets. For example,
use ``panel.Row`` to display multiple widgets horizontally.
widget_type : {'individual', 'scrubber'}, default='individual'
Whether to create one widget per grouped dimension or one scrubber
that steps through all combinations. Scrubbers require every grouped
dimension to define a finite set of values.
widgets : dict, optional
Mapping from grouped dimension names to Panel widget types or widget
instances, used to override the automatically selected widgets.

Axis Options
------------
Expand Down