!pip install bokeh
from bokeh.plotting import figure, output_file, save
from IPython.display import IFrame
from IPython.core.display import display, HTML
import tempfile
def bokeh_deepnote_show(plot):
tmp_output_filename = tempfile.NamedTemporaryFile(suffix='.html').name
output_file(tmp_output_filename)
save(plot)
f = open(tmp_output_filename, "r")
display(HTML(f.read()))
p = figure(title="Bokeh test", plot_width=300, plot_height=300)
p.circle([1, 2], [3, 4])
bokeh_deepnote_show(p)
!pip install networkx==2.5
# SEE: https://github.com/bokeh/bokeh/tree/2.2.3/examples
import networkx as nx
from bokeh.models import Range1d, Plot
from bokeh.plotting import from_networkx
G = nx.desargues_graph()
# We could use figure here but don't want all the axes and titles
plot = Plot(x_range=Range1d(-2, 2), y_range=Range1d(-2, 2))
# Create a Bokeh graph from the NetworkX input using nx.spring_layout
graph = from_networkx(G, nx.spring_layout, scale=1.8, center=(0,0))
plot.renderers.append(graph)
# Set some of the default node glyph (Circle) properties
graph.node_renderer.glyph.update(size=20, fill_color="orange")
# Set some edge properties too
graph.edge_renderer.glyph.line_dash = [2,2]
bokeh_deepnote_show(plot)
# SEE: https://github.com/bokeh/bokeh/tree/2.2.3/examples
from bokeh.transform import jitter
from bokeh.models import ColumnDataSource
from bokeh.sampledata.commits import data
DAYS = ['Sun', 'Sat', 'Fri', 'Thu', 'Wed', 'Tue', 'Mon']
source = ColumnDataSource(data)
p = figure(plot_width=800, plot_height=300, y_range=DAYS, x_axis_type='datetime',
title="Commits by Time of Day (US/Central) 2012—2016")
p.circle(x='time', y=jitter('day', width=0.6, range=p.y_range), source=source, alpha=0.3)
p.xaxis[0].formatter.days = ['%Hh']
p.x_range.range_padding = 0
p.ygrid.grid_line_color = None
bokeh_deepnote_show(p)