Skip to content

push_notebook doesn't update in VSCode .ipynb #199

@amarcuvitz

Description

@amarcuvitz

I am not able to get the various push_notebook examples to update when run as .ipynb files from VSCode. They work fine when run from a Jupyter notebook. Below is a simple standard example that runs in a Jupyter notebook but not in VSCode. I need to do Bokeh animation from within a VSCode development environment.

Isn’t this supposed to work as a cell in an .ipynb file executed in VSCode?

from bokeh.plotting import figure, show, output_notebook
from bokeh.models import ColumnDataSource
from bokeh.layouts import layout
from bokeh.io import push_notebook
import numpy as np
from time import sleep

# Output to Jupyter Notebook
output_notebook()

# Prepare some data
x = np.linspace(0, 4*np.pi, 100)
y = np.sin(x)
source = ColumnDataSource(data=dict(x=x, y=y))

# Create a new plot with a title and axis labels
p = figure(title="simple line example", x_axis_label='x', y_axis_label='y')

# Add a line renderer with legend and line thickness
p.line('x', 'y', source=source, legend_label="Temp.", line_width=2)

# Show the results
handle = show(p, notebook_handle=True)

# Update the plot
def update_plot(n_steps, sleep_time):
    for i in range(n_steps):
        y = np.sin(x + i/10.0)
        source.data = dict(x=x, y=y)
        push_notebook(handle=handle)
        sleep(sleep_time)

update_plot(100, 0.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions