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


Python transform.dodge方法代碼示例

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


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

示例1: _create_vert_range_tool

# 需要導入模塊: from bokeh import transform [as 別名]
# 或者: from bokeh.transform import dodge [as 別名]
def _create_vert_range_tool(
    data, min_y, max_y, plot_range, width, height, x_col, y_col, fill_map="navy"
):
    """Return vertical range too for plot."""
    rng_select = figure(
        plot_width=width,
        plot_height=height,
        y_range=(min_y - 1, max_y + 1),
        toolbar_location=None,
    )

    x_dodge = dodge(x_col, -0.5)
    rng_select.rect(
        x=x_dodge,
        y=y_col,
        width=1.2,
        height=0.8,
        source=data,
        fill_alpha=0.6,
        fill_color=fill_map,
    )

    rng_select.xaxis.visible = False
    rng_select.yaxis.visible = False

    range_tool = RangeTool(y_range=plot_range)
    range_tool.overlay.fill_color = "navy"
    range_tool.overlay.fill_alpha = 0.2
    rng_select.ygrid.grid_line_color = None
    rng_select.xgrid.grid_line_color = None
    rng_select.add_tools(range_tool)
    rng_select.toolbar.active_multi = range_tool
    return rng_select


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

示例2: get_data

# 需要導入模塊: from bokeh import transform [as 別名]
# 或者: from bokeh.transform import dodge [as 別名]
def get_data(self, element, ranges, style):
        style = self.style[self.cyclic_index]
        if 'angle' in style and isinstance(style['angle'], (int, float)):
            style['angle'] = np.deg2rad(style.get('angle', 0))

        dims = element.dimensions()
        coords = (1, 0) if self.invert_axes else (0, 1)
        xdim, ydim, tdim = (dimension_sanitizer(dims[i].name) for i in coords+(2,))
        mapping = dict(x=xdim, y=ydim, text=tdim)
        data = {d: element.dimension_values(d) for d in (xdim, ydim)}
        if self.xoffset is not None:
            mapping['x'] = dodge(xdim, self.xoffset)
        if self.yoffset is not None:
            mapping['y'] = dodge(ydim, self.yoffset)
        data[tdim] = [dims[2].pprint_value(v) for v in element.dimension_values(2)]
        self._categorize_data(data, (xdim, ydim), element.dimensions())

        cdim = element.get_dimension(self.color_index)
        if cdim is None:
            return data, mapping, style

        cdata, cmapping = self._get_color_data(element, ranges, style, name='text_color')
        if dims[2] is cdim and cdata:
            # If color dim is same as text dim, rename color column
            data['text_color'] = cdata[tdim]
            mapping['text_color'] = dict(cmapping['text_color'], field='text_color')
        else:
            data.update(cdata)
            mapping.update(cmapping)
        return data, mapping, style 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:32,代碼來源:annotation.py

示例3: whisker_quantiles

# 需要導入模塊: from bokeh import transform [as 別名]
# 或者: from bokeh.transform import dodge [as 別名]
def whisker_quantiles(data):
    """
    Data is expected as a dictionary {budget : {parameter : {folder : importance }}}
    """
    hyperparameters = []
    for hp2folders in data.values():
        for hp in hp2folders.keys():
            if not hp in hyperparameters:
                hyperparameters.append(hp)

    # Bokeh plot
    colors = itertools.cycle(d3['Category10'][10])

    # Create data to plot the error-bars (whiskers)
    whiskers_data = {}
    for budget in data.keys():
        whiskers_data.update({'base_' + str(budget): [], 'lower_' + str(budget): [], 'upper_' + str(budget): []})

    # Generate whiskers data in bokeh-ColumnDataSource
    for (budget, imp_dict) in data.items():
        for p, imp in imp_dict.items():
            mean = np.nanmean(np.array(list(imp.values())))
            std = np.nanstd(np.array(list(imp.values())))
            if not np.isnan(mean) and not np.isnan(std):
                whiskers_data['lower_' + str(budget)].append(mean - std)
                whiskers_data['upper_' + str(budget)].append(mean + std)
                whiskers_data['base_' + str(budget)].append(p)
    whiskers_datasource = ColumnDataSource(whiskers_data)

    plot = figure(x_range=FactorRange(factors=hyperparameters, bounds='auto'),
                  y_range=Range1d(0, 1, bounds='auto'),
                  plot_width=800, plot_height=300,
                  )
    dodgies = np.linspace(-0.25, 0.25, len(data)) if len(data) > 1 else [0]  # No dodge if only one budget
    # Plot
    for (budget, imp_dict), d, color in zip(data.items(), dodgies, colors):
        for p, imp in imp_dict.items():
            for i in imp.values():
                if np.isnan(i):
                    continue
                plot.circle(x=[(p, d)], y=[i], color=color, fill_alpha=0.4,
                            legend="Budget %s" % str(budget) if len(data) > 1 else '')

        if not 'base_' + str(budget) in whiskers_data:
            continue
        plot.add_layout(Whisker(source=whiskers_datasource,
                                base=dodge('base_' + str(budget), d, plot.x_range),
                                lower='lower_' + str(budget),
                                upper='upper_' + str(budget),
                                line_color=color))
    plot.yaxis.axis_label = "Importance"

    return plot 
開發者ID:automl,項目名稱:CAVE,代碼行數:55,代碼來源:whisker_quantiles.py

示例4: _create_plot

# 需要導入模塊: from bokeh import transform [as 別名]
# 或者: from bokeh.transform import dodge [as 別名]
def _create_plot() -> (Figure, ColumnDataSource):
    """Utility function for creating and styling the bar plot."""
    global source, aspects, stats
    pos_counts, neg_counts = (
        [stats.loc[(asp, pol, False), "Quantity"] for asp in aspects] for pol in POLARITIES
    )
    np.seterr(divide="ignore")
    source = ColumnDataSource(
        data={
            "aspects": aspects,
            "POS": pos_counts,
            "NEG": neg_counts,
            "log-POS": np.log2(pos_counts),
            "log-NEG": np.log2(neg_counts),
        }
    )
    np.seterr(divide="warn")
    p = figure(
        plot_height=145,
        sizing_mode="scale_width",
        x_range=aspects,
        toolbar_location="right",
        tools="save, tap",
    )
    rs = [
        p.vbar(
            x=dodge("aspects", -0.207, range=p.x_range),
            top="log-POS",
            width=0.4,
            source=source,
            color="limegreen",
            legend=value("POS"),
            name="POS",
        ),
        p.vbar(
            x=dodge("aspects", 0.207, range=p.x_range),
            top="log-NEG",
            width=0.4,
            source=source,
            color="orangered",
            legend=value("NEG"),
            name="NEG",
        ),
    ]
    for r in rs:
        p.add_tools(
            HoverTool(tooltips=[("Aspect", "@aspects"), (r.name, "@" + r.name)], renderers=[r])
        )
    p.add_layout(
        Title(text=" " * 7 + "Sentiment Count (log scale)", align="left", text_font_size="23px"),
        "left",
    )
    p.yaxis.ticker = []
    p.y_range.start = 0
    p.xgrid.grid_line_color = None
    p.xaxis.major_label_text_font_size = "20pt"
    p.legend.label_text_font_size = "20pt"
    return p, source 
開發者ID:NervanaSystems,項目名稱:nlp-architect,代碼行數:60,代碼來源:absa_solution.py


注:本文中的bokeh.transform.dodge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。