Embedding in a notebook

You can update a diagram without reloading it. To do this, pass notebook_handle=True to show() so that it returns a handle object. You can then use this handle object with the push_notebook() function to update the diagram.

1. Imports

[1]:
from bokeh.io import output_notebook, show


output_notebook()
Loading BokehJS ...
  • output_notebook configures the status for the output of show().

  • show immediately displays a bokeh object or an application.

2. Create some plots and pass them to show():

[2]:
import pandas as pd

from bokeh.plotting import figure
from bokeh.sampledata.stocks import AAPL


df = pd.DataFrame(AAPL)
df["date"] = pd.to_datetime(df["date"])
[3]:
p = figure(width=616, height=250, x_axis_type="datetime")
p.line(df["date"], df["close"], color="navy", alpha=0.5)

show(p, notebook_handle=True)
[3]:

<Bokeh Notebook handle for In[3]>