Plot with columns

Download this notebook from GitHub (right-click to download).

In [ ]:
import panel as pn
import hvplot.pandas

from bokeh.sampledata.autompg import autompg_clean


This example demonstrates how to combine multiple columns of widgets into layout an overall layout.

In [ ]:
quant = [None, 'mpg', 'cyl', 'displ', 'hp', 'weight', 'yr']
cat = [None, 'origin', 'mfr', 'yr']
combined = quant+cat[1:]

x = pn.widgets.Select(name='x', value='mpg', options=combined)
y = pn.widgets.Select(name='y', value='cyl', options=combined)
color = pn.widgets.Select(name='color', options=combined)
facet = pn.widgets.Select(name='facet', options=cat)

@pn.depends(x.param.value, y.param.value, color.param.value, facet.param.value)
def plot(x, y, color, facet):
    cmap = 'Category10' if color in cat else 'viridis'
    return autompg_clean.hvplot.scatter(
        x, y, color=color, by=facet, subplots=True, padding=0.1, width=None, height=None, cmap=cmap).opts(
        'Scatter', min_height=300, responsive=True, min_width=200)

    '### Auto MPG Explorer', 
    pn.Row(pn.WidgetBox(x, y, color), pn.WidgetBox(facet)),

Download this notebook from GitHub (right-click to download).