当前位置: 首页>>代码示例>>Python>>正文


Python plotting.save方法代码示例

本文整理汇总了Python中bokeh.plotting.save方法的典型用法代码示例。如果您正苦于以下问题:Python plotting.save方法的具体用法?Python plotting.save怎么用?Python plotting.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.plotting的用法示例。


在下文中一共展示了plotting.save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_graphs

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import save [as 别名]
def update_graphs(project_code, html_path):
    pd.set_option('display.width', 1800)
    html_path = op.join(html_path, "{0}.html".format(project_code))

    qc_path = op.dirname(op.abspath(__file__))
    commands_dir = op.dirname(qc_path)
    root_dir = op.dirname(commands_dir)
    log_dir = op.join(root_dir, "logs")

    csv_path = op.join(log_dir, project_code + ".csv")

    csv = pd.read_csv(csv_path, delimiter=";")
    csv.timeStamp = pd.to_datetime(csv.timeStamp)

    output_file(html_path, mode="inline")

    topics = {"q_": "QC",
              "l_": "LINKS",
              "g_": "GROUPS",
              "v_": "VIEWS",
              "d_": "2D",
              "s_": "STYLES",
              "e_": "ELEMENTS",
              "m_": "PROJECT_SQM",
              }

    graphs = graph(csv, project_code, topics)

    save(column(graphs), validate=False)
    print(colorful.bold_green(f" {html_path} updated successfully.")) 
开发者ID:hdm-dt-fb,项目名称:rvt_model_services,代码行数:32,代码来源:bokeh_qc_graphs.py

示例2: bokehFigure

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import save [as 别名]
def bokehFigure(**kwargs):
        
    """
    Builds foundation for the bokeh subplots
    
    **kwargs can include any keyword argument that would be passable to a bokeh figure().
    See https://docs.bokeh.org/en/latest/docs/reference/plotting.html for a complete list.
    
    The main argument passed is usually 'title'. If they are not defined, 'tools',
    'plot_width', 'plot_height', and 'x_axis_type' are populated with default values.
    
    """
    
    # default values for bokehFigures
    if 'tools' not in kwargs:
        kwargs['tools'] = ['pan,box_zoom,reset,save,tap']
    if 'plot_width' not in kwargs:
        kwargs['plot_width'] = 1250
    if 'plot_height' not in kwargs:
        kwargs['plot_height'] = 250
    if 'x_axis_type' not in kwargs:
        kwargs['x_axis_type'] = 'datetime'
        
    # Create figure
    fig = figure(**kwargs)
        
    fig.grid.grid_line_alpha = 0.3
    fig.xaxis.axis_label = 'Date'
    fig.yaxis.axis_label = ''
    
    return fig 
开发者ID:ahotovec,项目名称:REDPy,代码行数:33,代码来源:plotting.py

示例3: graph

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import save [as 别名]
def graph(_csv, _project_code, graph_topics):
    figures = []
    graph_x_range = None
    for topic in graph_topics.keys():
        # data source
        csv_topic = _csv.copy().filter(regex=topic)
        csv_topic["timeStamp"] = _csv.timeStamp.copy()
        csv_topic.set_index('timeStamp', inplace=True)
        csv_topic.index = pd.to_datetime(csv_topic.index)
        csv_topic.sort_index(inplace=True)
        df_columns_count = csv_topic.shape[1]
        df_rows_count = csv_topic.shape[0]

        colors = viridis(df_columns_count)

        topic_title = f"{_project_code} - RVT - {graph_topics[topic]}"

        # print(topic_title)
        # print(csv_topic.head())

        line_opt = dict(line_width=3, alpha=0.8)
        hover = HoverTool(tooltips=[("name", "@name"),
                                    ("time", "@time"),
                                    ("count", "@count"),
                                    ]
                          )
        tools_opt = [hover, "save", "pan", "wheel_zoom", "reset"]
        graph_opt = dict(width=900, x_axis_type="datetime",
                         toolbar_location="left", tools=tools_opt, toolbar_sticky=False,
                         background_fill_alpha=0, border_fill_alpha=0)

        if graph_x_range:
            topic_figure = figure(title=topic_title, x_range=graph_x_range, **graph_opt)
        else:
            topic_figure = figure(title=topic_title, **graph_opt)
            graph_x_range = topic_figure.x_range

        # glyphs
        # print(len(cds.column_names))
        for i, col_name in enumerate(csv_topic.columns):
            if topic in col_name:
                # print(col_name)
                csv_topic["color"] = colors[i]
                name_list = [col_name[2:] for i in range(df_rows_count)]

                cds = ColumnDataSource(data=dict(x=csv_topic.index.values,
                                                 y=csv_topic[col_name].values,
                                                 name=name_list,
                                                 count=csv_topic[col_name].values,
                                                 time=csv_topic.index.strftime("%Y-%m-%d %H:%M:%S"),
                                                 )
                                       )

                topic_figure.line("x", "y",
                                  color=colors[i], name="name", source=cds, legend=col_name[2:],
                                  **line_opt
                                  )

        figures.append(style_plot(topic_figure))

    return figures 
开发者ID:hdm-dt-fb,项目名称:rvt_model_services,代码行数:63,代码来源:bokeh_qc_graphs.py

示例4: update_graph

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import save [as 别名]
def update_graph(jobs_db, graph_path):
    rows = []
    for job in jobs_db.all():
        rows.append([job.get("<project_code>"), job.get("<command>"), job.get(">start_time"), job.get("timeout")])

    df = pd.DataFrame(rows, columns=["project", "command", "start", "timeout"])
    df = df.sort_values(by="project", ascending=False)
    df["start"] = pd.to_datetime(df["start"], format="%H:%M:%S")
    df["start_txt"] = df.start.astype("str").str.extract(r"(\d+:\d+)", expand=True) + " h"
    df["timeout_txt"] = df['timeout'].copy().astype('str') + " seconds"
    df["timeout"] = df['timeout'].astype('timedelta64[s]')
    df["end"] = pd.to_datetime(df["start"], format="%H:%M:%S") + df["timeout"]

    colors = viridis(len(df["project"]))
    output_file(graph_path, title="rvt_model_services_jobs", mode="inline")

    cds = ColumnDataSource(data=dict(start=df["start"].values,
                                     end=df["end"].values,
                                     name=df["project"],
                                     timeout=df["timeout_txt"],
                                     start_txt=df["start_txt"],
                                     command=df["command"],
                                     color=colors,
                                     )
                           )

    hover = HoverTool(tooltips=[("project", "@name"),
                                ("command", "@command"),
                                ("start time:", "@start_txt"),
                                ("timeout:", "@timeout"),
                                ])

    tools_opt = [hover, "save", "pan", "wheel_zoom", "box_zoom", "reset"]
    graph_opt = dict(width=900, x_axis_type="datetime",
                     tools=tools_opt,
                     toolbar_location="right",
                     background_fill_alpha=0, border_fill_alpha=0)
    jobs_viz = figure(title="rvt_model_service_jobs",
                      y_range=list(df["project"].unique()),
                      **graph_opt)
    jobs_viz.hbar(source=cds,
                  y="name",
                  left="start",
                  right="end",
                  height=1,
                  color="color",
                  )

    style_plot(jobs_viz)
    save(jobs_viz) 
开发者ID:hdm-dt-fb,项目名称:rvt_model_services,代码行数:52,代码来源:bokeh_jobs_viz.py


注:本文中的bokeh.plotting.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。