在 Jupyter 筆記本中使用 Bokeh
這是一個如何在 Jupyter Notebook 中使用 Bokeh 的簡單示例:
import numpy as np
from bokeh.plotting import figure
# Make Bokeh Push push output to Jupyter Notebook.
from bokeh.io import push_notebook, show, output_notebook
from bokeh.resources import INLINE
output_notebook(resources=INLINE)
# Create some data.
x = np.linspace(0,2*np.pi,20)
y = np.sin(x)
# Create a new plot with a title and axis labels
p = figure(title="Simple Line Plot in Bokeh", x_axis_label='x', y_axis_label='y')
# Add a line renderer with legend and line thickness
p.line(x, y, legend="Value", line_width=3)
# Show the results
show(p)