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, y, color, facet)
def plot(x, y, color, facet):
    cmap = 'Category10' if color in cat else 'viridis'
    return autompg_clean.hvplot.scatter(
        x, y, color=color or 'darkblue', by=facet, subplots=True, padding=0.1,
        cmap=cmap, responsive=True, min_height=300

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

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