Nextjournal / Aug 11 2020
Bokeh Template
setup notebook output by running the following cell once
import bokeh_nextjournalfrom bokeh.io import output_notebookoutput_notebook(notebook_type='nextjournal')1.0s
Bokeh Runtime (Python)
Bokeh Nextjournal Support
import numpy as npfrom scipy.integrate import odeintfrom bokeh.plotting import figure, output_file, showsigma = 10rho = 28beta = 8.0/3theta = 3 * np.pi / 4def 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) * ycolors = ["#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_hookfrom bokeh.embed.standalone import file_htmlfrom bokeh.settings import settingsfrom bokeh.resources import Resourcesfrom IPython.display import publish_display_datadef 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