我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用bokeh.plotting.output_file()。
def weight(repo, compare_repo=None): repo_saving, compare_saving, compare_name = _combine_repo(repo, compare_repo, 'trainable_params') def show(attr, old, new): layername = new g = [[]] for i, (wtname, wt) in enumerate(repo_saving[layername].items()): if wt.ndim == 4: wt.transpose(0, 2, 1, 3) wt.reshape([wt.shape[:2], wt.shape[2:]]) p = plt.figure(plot_width=100, plot_height=100, title=wtname, tools=[]) if wt.ndim == 1: p.line(range(wt.shape[0]), wt, line_width=2, color='black') else: p.image([wt], [0], [0], [p.x_range[-1]], [p.y_range[-1]]) g[-1].append(p) if (i + 1) % 5 == 0: g.append([]) v = lyt.gridplot(g, toolbar_location="below", merge_tools=True) plt.output_file('./weightplot.html', title='WeightPlot') select = models.widgets.Select(title="Layer:", value=repo_saving.keys()[0], options=repo_saving.keys()) select.on_change("value", show) plt.save(lyt.widgetbox(select))
def output_file(suppress_warnings=True): if suppress_warnings: warnings.simplefilter("ignore", BokehUserWarning) bk.output_file(os.path.join(tempfile.gettempdir(), str(uuid.uuid4()) + ".html"))
def show_mpl2bokeh(**kwargs): """ """ if not _use_bkh: raise ImportError("failed to import bokeh: try 'sudo pip install bokeh' or choose another plotting backend") bkh.output_file('_bkh.html', title='') show_bokeh(ax=bkhmpl.to_bokeh())