当前位置: 首页>>代码示例>>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;未经允许,请勿转载。