Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can one switch between output_notebook and output_file within an IPython notebook session with Bokeh?

Tags:

python

bokeh

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.

like image 962
Chris Fonnesbeck Avatar asked Sep 19 '14 14:09

Chris Fonnesbeck


1 Answers

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.

like image 100
paavo Avatar answered Oct 02 '22 18:10

paavo