displays.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:triflow 作者: locie 项目源码 文件源码
def __init__(self, simul, probes,
                 line_kwargs={},
                 fig_kwargs={},
                 default_fig_kwargs={"width": 600, "height": 400},
                 default_line_kwargs={},
                 notebook=True):

        from bokeh.io import push_notebook, output_notebook
        from bokeh.plotting import figure, show, ColumnDataSource
        from bokeh.layouts import Column

        if notebook:
            output_notebook()

        setattr(self, '_push', push_notebook)
        self._datasource = ColumnDataSource(dict(t=[simul.t],
                                                 **{name: [probe(simul.t,
                                                                 simul.fields)]
                                                    for name, probe
                                                    in probes.items()}))
        figs = {}
        for name, probe in probes.items():
            fig_config = default_fig_kwargs.copy()
            fig_config.update(fig_kwargs.get(name, {}))
            line_config = default_line_kwargs.copy()
            line_config.update(line_kwargs.get(name, {}))
            figs[name] = figure(**fig_config, title=name)
            figs[name].line('t', name, source=self._datasource,
                            **line_config)
        self._handler = show(Column(*[figs[name] for name in probes]),
                             notebook_handle=True)
        self._probes = probes
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号