首页 文章

散景:保存情节但不显示

提问于
浏览
20

我正在使用Bokeh生成HTML代码,包括带有 show 方法的图形 . 此方法以打开默认浏览器并打开HTML结束 .

我想保存HTML代码,而不显示它 . 我怎样才能做到这一点 ?

2 回答

  • 6

    使用 output_file({file_name}) 而不是 output_notebook() . 您可以调用 saveshow 方法 . 请记住,每次调用save或show方法时,文件都将被重写 .

    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)
    
  • 22

    解决方案是通过调用 save 替换对 show 的调用 .

相关问题