visualizations.py 文件源码

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

项目:crowddynamics 作者: jaantollander 项目源码 文件源码
def figure(filename, show=False, save=False, **kwargs):
    """Context manager for using :class:`bokeh.plotting.figure`.

    Args:
        filename (str):
        show (bool):
        save (bool):

    Yields:
        Figure:

    Examples:
        >>> with figure('figure.html', show=True, save=False) as p:
        >>>     p.patch(...)
    """
    base, ext = os.path.splitext(filename)
    _, name = os.path.split(base)
    if ext != '.html':
        filename += '.html'

    bokeh.io.output_file(filename, name)
    fig = bokeh.plotting.Figure(**kwargs)

    yield fig

    if show:
        bokeh.io.show(fig)

    if save:
        bokeh.io.save(fig)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号