Bokeh 简明教程

Bokeh - Jupyter Notebook

在 Jupyter 笔记本中显示 Bokeh 图与上述图非常相似。您需要进行的唯一更改是从 bokeh.plotting 模块导入 output_notebook 而不是 output_file。

Displaying Bokeh figure in Jupyter notebook is very similar to the above. The only change you need to make is to import output_notebook instead of output_file from bokeh.plotting module.

from bokeh.plotting import figure, output_notebook, show

调用 output_notebook() 函数将 Jupyter 笔记本的输出单元格设置为 show() 函数的目标,如下所示 -

Call to output_notebook() function sets Jupyter notebook’s output cell as the destination for show() function as shown below −

output_notebook()
show(p)

在一本笔记本单元格中输入代码并运行它。正弦波将显示在笔记本内。

Enter the code in a notebook cell and run it. The sine wave will be displayed inside the notebook.