是否可以在与Bokeh的IPython Notebook会话中的output_notebook和output_file之间切换? [英] Can one switch between output_notebook and output_file within an IPython notebook session with Bokeh?

查看:142
本文介绍了是否可以在与Bokeh的IPython Notebook会话中的output_notebook和output_file之间切换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以在同一IPython笔记本中使用Bokeh生成静态HTML输出和内联图.我现在看到的是,一旦我调用output_notebook()output_file("myfile.html"),我就会被卡在那种输出方式上.例如,如果我最初使用output_notebook,则随后调用output_file不会创建输出文件.

I'm wondering if it is possible to generate static HTML output and inline plots using Bokeh in the same IPython notebook. What I am currently seeing is that once I either call output_notebook() or output_file("myfile.html") I am stuck using that output modality. For example, if I initially use output_notebook, subsequently calling output_file does not create an output file.

推荐答案

reset_output()至少在版本0.10.0中有效.

reset_output() before the next output_notebook or output_file call works at least in version 0.10.0 .

# cell 1
from bokeh.plotting import figure, show, output_notebook, output_file, reset_output
p = figure(width=300, height=300)
p.line(range(5), range(5))
output_notebook()
show(p)

# cell 2
reset_output()
output_file('foo.html')
show(p)

# cell 3
reset_output()
output_notebook()
show(p)

笔记本中的第一和第三个节目,浏览器中的第二个节目.

First and third show in notebook, second shows in browser.

这篇关于是否可以在与Bokeh的IPython Notebook会话中的output_notebook和output_file之间切换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆