31

I am using Bokeh to produce HTML code including figures with show method This method ends on opening default browser with HTML opened in it.

I want to save the HTML code, without showing it. How can I do that ?

smci
  • 32,567
  • 20
  • 113
  • 146
RandomCoder
  • 6,606
  • 6
  • 22
  • 28

2 Answers2

33

Solution is to replace calls to show by calls to save.

RandomCoder
  • 6,606
  • 6
  • 22
  • 28
  • 2
    Also if you would like to save custom HTML, or plots embedded in your own templates: http://bokeh.pydata.org/en/latest/docs/user_guide/embed.html – bigreddot Jul 22 '15 at 13:11
18

Use output_file({file_name}) instead of output_notebook(). You can call either save or show method. Remember each time you call save or show method the file will be rewritten.

bokeh.io documentation

from bokeh.plotting import figure, output_file, save

p = figure(title="Basic Title", plot_width=300, plot_height=300)
p.circle([1, 2], [3, 4])
output_file("output_file_name.html")
save(p)
Athena
  • 3,200
  • 3
  • 27
  • 35
Venkatesh Mondi
  • 717
  • 9
  • 18