散景未显示在 jupyter 笔记本中

Mik*_*ike 4 bokeh jupyter-notebook

我什至无法在 Jupyter Notebook 中绘制最基本的散景图。我进行了搜索,可以看到这是一年多前报告的问题,但此后什么也没有 - 对其他人来说仍然是问题吗?

from bokeh.io import output_notebook, show
from bokeh.plotting import figure

output_notebook()

p = figure(plot_width=400, plot_height=400)

p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=15, line_color="navy", 
fill_color="orange", fill_alpha=0.5)

show(p)
Run Code Online (Sandbox Code Playgroud)

我得到“BokehJS 0.12.10 成功加载”。消息,但不是情节。请注意,它可以正常输出 html 文件。

我尝试使用以下方法更改环境变量:

import os
os.environ['BOKEH_RESOURCES'] = 'inline'
Run Code Online (Sandbox Code Playgroud)

但这也没有影响。这是一个令人沮丧的下午,所以任何帮助将不胜感激!

小智 9

运行下面的行对我有用

from bokeh.resources import INLINE
import bokeh.io
from bokeh import *
bokeh.io.output_notebook(INLINE)
Run Code Online (Sandbox Code Playgroud)


big*_*dot 1

我的猜测是你的笔记本版本太旧了。根本没有技术途径可以同时支持新的 JupyterLab 和 5.0 之前的经典笔记本版本。支持 JupyterLab 势在必行,因此截至目前,Bokeh 只能支持经典笔记本 5.0 及更高版本。所以你可以:

  • 降级 Bokeh (<= 10.12.8),或
  • 升级 Jupyter Notebook (>= 5.0),或
  • 切换到最近的 JupyterLab 测试版。您需要安装 Jupyter 扩展

    jupyter labextension install jupyterlab_bokeh
    
    Run Code Online (Sandbox Code Playgroud)