Bokeh Template

setup notebook output by running the following cell once

import bokeh_nextjournal
from bokeh.io import output_notebook
output_notebook(notebook_type='nextjournal')
1.0s
Bokeh Runtime (Python)
Bokeh Nextjournal Support
import numpy as np
from scipy.integrate import odeint
from bokeh.plotting import figure, output_file, show
sigma = 10
rho = 28
beta = 8.0/3
theta = 3 * np.pi / 4
def lorenz(xyz, t):
    x, y, z = xyz
    x_dot = sigma * (y - x)
    y_dot = x * rho - x * z - y
    z_dot = x * y - beta* z
    return [x_dot, y_dot, z_dot]
initial = (-10, -7, 35)
t = np.arange(0, 100, 0.006)
solution = odeint(lorenz, initial, t)
x = solution[:, 0]
y = solution[:, 1]
z = solution[:, 2]
xprime = np.cos(theta) * x - np.sin(theta) * y
colors = ["#C6DBEF", "#9ECAE1", "#6BAED6", "#4292C6", "#2171B5", "#08519C", "#08306B",]
p = figure(title="Lorenz attractor example", background_fill_color="#fafafa")
q = figure(title="Circles", plot_width=400, plot_height=400)
p.multi_line(np.array_split(xprime, 7), np.array_split(z, 7),
             line_color=colors, line_alpha=0.8, line_width=1.5)
q.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
show(p)
show(q)
1.2s
Bokeh Runtime (Python)

Setup

This python module sets up bokeh notebook output for nextjournal

from bokeh.io.notebook import install_notebook_hook
from bokeh.embed.standalone import file_html
from bokeh.settings import settings
from bokeh.resources import Resources
from IPython.display import publish_display_data
def load(resources=None, 
         verbose=False, 
         hide_banner=False, 
         load_timeout=5000):
  banner = '''<span class="teal">Bokeh Nextjournal Support</span>'''
  if not hide_banner:
    publish_display_data({'text/html': banner})
def show_doc(obj, state, handle): 
  resources = Resources(mode=settings.resources())
  html = file_html(obj, resources, title='nj') #, template=template)
  publish_display_data({'text/html': html})
def show_app(app, state, notebook_url, port=0, **kw):
  error = '<span class="red">Bokeh Applications not supported in Nexjournal</span>'
  publish_display_data({'text/html': error})
install_notebook_hook('nextjournal', 
                      load, show_doc, show_app, overwrite=True)
bokeh_nextjournal.py
Python

Runtimes (1)