同じ IPython ノートブックで Bokeh を使用して、静的な HTML 出力とインライン プロットを生成できるかどうか疑問に思っています。私が現在見ているのは、一度呼び出すoutput_notebook()
かoutput_file("myfile.html")
、その出力モダリティを使用して立ち往生していることです。たとえば、最初に を使用するoutput_notebook
と、その後呼び出しoutput_file
ても出力ファイルが作成されません。
3411 次
2 に答える
11
reset_output()
次のoutput_notebook
またはoutput_file
呼び出しの前に、少なくともバージョン 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)
1 番目と 3 番目はノートブックで表示され、2 番目はブラウザーで表示されます。
于 2016-01-14T16:26:25.453 に答える
0
次のコードを使用して、静的 HTML を作成できます (こちらの例から変更)。
from bokeh.plotting import figure
from bokeh.resources import CDN
from bokeh.embed import file_html
plot = figure()
plot.circle([1,2], [3,4])
html = file_html(plot, CDN, "my plot")
with open('test.html', 'w') as f:
f.write(html)
これは、と組み合わせて問題なく動作しますoutput_notebook()
于 2015-10-03T06:12:19.330 に答える