當前位置: 首頁>>代碼示例>>Python>>正文


Python palettes.viridis方法代碼示例

本文整理匯總了Python中bokeh.palettes.viridis方法的典型用法代碼示例。如果您正苦於以下問題:Python palettes.viridis方法的具體用法?Python palettes.viridis怎麽用?Python palettes.viridis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在bokeh.palettes的用法示例。


在下文中一共展示了palettes.viridis方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _create_fill_map

# 需要導入模塊: from bokeh import palettes [as 別名]
# 或者: from bokeh.palettes import viridis [as 別名]
def _create_fill_map(
    source: ColumnDataSource, source_column: str = None
) -> Tuple[Union[factor_cmap, linear_cmap], Optional[ColorBar]]:
    """Create factor map or linear map based on `source_column`."""
    fill_map = "navy"
    color_bar = None
    if source_column is None or source_column not in source.data:
        return fill_map, color_bar

    col_kind = source.data[source_column].dtype.kind
    if col_kind in ["b", "O"]:
        s_values = set(source.data[source_column])
        if np.nan in s_values:
            s_values.remove(np.nan)
        values = list(s_values)
        fill_map = factor_cmap(
            source_column, palette=viridis(max(3, len(values))), factors=values
        )
    elif col_kind in ["i", "u", "f", "M"]:
        values = [val for val in source.data[source_column] if not np.isnan(val)]
        fill_map = linear_cmap(
            field_name=source_column,
            palette=viridis(256),
            low=np.min(values),
            high=np.max(values),
        )
        color_bar = ColorBar(
            color_mapper=fill_map["transform"], width=8, location=(0, 0)  # type: ignore
        )
    return fill_map, color_bar


# pylint: disable=too-many-arguments 
開發者ID:microsoft,項目名稱:msticpy,代碼行數:35,代碼來源:process_tree.py

示例2: _get_color_palette

# 需要導入模塊: from bokeh import palettes [as 別名]
# 或者: from bokeh.palettes import viridis [as 別名]
def _get_color_palette(series_count):
    palette_size = min(256, series_count + int(series_count / 5))
    return viridis(palette_size), palette_size 
開發者ID:microsoft,項目名稱:msticpy,代碼行數:5,代碼來源:timeline.py

示例3: graph

# 需要導入模塊: from bokeh import palettes [as 別名]
# 或者: from bokeh.palettes import viridis [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 palettes [as 別名]
# 或者: from bokeh.palettes import viridis [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.palettes.viridis方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。