Plotting multiple lines with DynamicMap?

Hey guys. Was just following the example on the HoloViews website:

Under the section titled “Building Dashboards”, there is an amazingly clean plot where you can pick the stock and the Y-axis and plot it. Best of all you can save the fully interactive plot to a HTML file!

The only problem is that I don’t understand a way to plot multiple lines on this. For example, I tried changing the radiobutton widget to a toggle widget (to allow me to plot multiple stocks rather than just one), but this threw an error:

“TypeError: getattr(): attribute name must be string”

Which I presume is because the attribute changes from a string to a list when you go from a radio button to a toggle widget.


!pip install holoviews
!pip install bokeh

import pandas as pd
import holoviews as hv
import bokeh.sampledata

from bokeh.sampledata import stocks
from holoviews.operation.timeseries import rolling, rolling_outlier_std


def load_symbol(symbol, variable, **kwargs):
    df = pd.DataFrame(getattr(stocks, symbol))
    df['date'] ='datetime64[ns]')
    return hv.Curve(df, ('date', 'Date'), variable).opts(framewise=True)

stock_symbols = ['AAPL', 'IBM', 'FB', 'GOOG', 'MSFT']
variables = ['open', 'high', 'low', 'close', 'volume', 'adj_close']

import panel as pn

symbol = pn.widgets.RadioButtonGroup(options=stock_symbols)
variable = pn.widgets.Select(options=variables)
rolling_window = pn.widgets.IntSlider(name='Rolling Window', value=10, start=1, end=365)

pn.Column(symbol, variable, rolling_window)

dmap = hv.DynamicMap(pn.bind(load_symbol, symbol=symbol, variable=variable))
smoothed = rolling(dmap, rolling_window=rolling_window)

app = pn.Row(pn.WidgetBox('## Stock Explorer', symbol, variable, rolling_window), 
             smoothed.opts(width=500, framewise=True)).servable()