Live plot with interactivity

Yes, here is an updated version from that example:

class bkapp:  
    df = sea_surface_temperature.copy()

    def __init__(self):
        self._theme_json = """
           attrs:
                figure:
                    background_fill_color: "#DDDDDD"
                    outline_line_color: white
                    toolbar_location: above
                    height: 500
                    width: 800
                Grid:
                    grid_line_dash: [6, 4]
                    grid_line_color: white
        """

    def callback(self, attr, old, new):
        if new == 0:
            data = self.df
        else:
            data = self.df.rolling('{0}D'.format(new)).mean()
        self.source.data = ColumnDataSource.from_df(data)

    def __call__(self, doc):
        self.source = ColumnDataSource(data=self.df)
    
        plot = figure(x_axis_type='datetime', y_range=(0, 25),
                      y_axis_label='Temperature (Celsius)',
                      title="Sea Surface Temperature at 43.18, -70.43")
        plot.line('time', 'temperature', source=self.source)
    
        slider = Slider(start=0, end=30, value=0, step=1, title="Smoothing by N Days")
        slider.on_change('value', self.callback)
    
        doc.add_root(column(slider, plot))

Then call with

show(bkapp()) # pass an instance to show

I’ll make an issue to add this version to the docs and “officially” support it.

Edit: