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


Python models.Span方法代码示例

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


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

示例1: vlines

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Span [as 别名]
def vlines(x, color='gray', style='dashed', thickness=1, hold=False):
    """Draw vertical lines on a plot.

    :param x: x location of lines
    :param color: line color (see `Bokeh colors`_)
    :param style: line style ('solid', 'dashed', 'dotted', 'dotdash', 'dashdot')
    :param thickness: line width in pixels
    :param hold: if set to True, output is not plotted immediately, but combined with the next plot

    >>> import arlpy.plot
    >>> arlpy.plot.plot([0, 20], [0, 10], hold=True)
    >>> arlpy.plot.vlines([7, 12])
    """
    global _figure
    if _figure is None:
        return
    x = _np.array(x, ndmin=1, dtype=_np.float, copy=False)
    for j in range(x.size):
        _figure.add_layout(_bmodels.Span(location=x[j], dimension='height', line_color=color, line_dash=style, line_width=thickness))
    if not hold and not _hold:
        _show(_figure)
        _figure = None 
开发者ID:org-arl,项目名称:arlpy,代码行数:24,代码来源:plot.py

示例2: hlines

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Span [as 别名]
def hlines(y, color='gray', style='dashed', thickness=1, hold=False):
    """Draw horizontal lines on a plot.

    :param y: y location of lines
    :param color: line color (see `Bokeh colors`_)
    :param style: line style ('solid', 'dashed', 'dotted', 'dotdash', 'dashdot')
    :param thickness: line width in pixels
    :param hold: if set to True, output is not plotted immediately, but combined with the next plot

    >>> import arlpy.plot
    >>> arlpy.plot.plot([0, 20], [0, 10], hold=True)
    >>> arlpy.plot.hlines(3, color='red', style='dotted')
    """
    global _figure
    if _figure is None:
        return
    y = _np.array(y, ndmin=1, dtype=_np.float, copy=False)
    for j in range(y.size):
        _figure.add_layout(_bmodels.Span(location=y[j], dimension='width', line_color=color, line_dash=style, line_width=thickness))
    if not hold and not _hold:
        _show(_figure)
        _figure = None 
开发者ID:org-arl,项目名称:arlpy,代码行数:24,代码来源:plot.py

示例3: _plot_hlines

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Span [as 别名]
def _plot_hlines(self, obj):
        hlines = obj.plotinfo._get('plothlines', [])
        if not hlines:
            hlines = obj.plotinfo._get('plotyhlines', [])

        # Horizontal Lines
        hline_color = convert_color(self._scheme.hlinescolor)
        for hline in hlines:
            span = Span(location=hline,
                        dimension='width',
                        line_color=hline_color,
                        line_dash=convert_linestyle(self._scheme.hlinesstyle),
                        line_width=self._scheme.hlineswidth)
            self.figure.renderers.append(span) 
开发者ID:verybadsoldier,项目名称:backtrader_plotting,代码行数:16,代码来源:figureenvelope.py

示例4: _init_glyph

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Span [as 别名]
def _init_glyph(self, plot, mapping, properties):
        """
        Returns a Bokeh glyph object.
        """
        box = Span(level=properties.get('level', 'glyph'), **mapping)
        plot.renderers.append(box)
        return None, box 
开发者ID:holoviz,项目名称:holoviews,代码行数:9,代码来源:annotation.py

示例5: bokeh_plot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Span [as 别名]
def bokeh_plot(self):
        if self._bokeh_plot is None:
            spinflag = False
            if len(self.dos) == 2:
                spinflag = True

            if spinflag:
                source = bkp.ColumnDataSource(data=dict(
                    en = self.energy,
                    up = self.dos[0],
                    down = -self.dos[1],
                ))
            else:
                source = bkp.ColumnDataSource(data=dict(
                    en = self.energy,
                    dos = self.dos[0],
                ))

            p = bkp.figure(width=500, height=300,
                           x_range=(-6, 6),
                           tools=['pan', 'box_zoom', 'hover', 'reset', 'save', 'help'])

            p.title.text = 'Density of States'
            p.title.align = 'center'
            p.title.text_font_size = "15pt"

            p.xaxis.axis_label = u'E \u2212 E_Fermi (eV)'
            p.xaxis.axis_label_text_font_size = '14pt'
            p.xaxis.major_label_text_font_size = '12pt'

            p.yaxis.axis_label = '# of states (arb. units)'
            p.yaxis.axis_label_text_font_size = '14pt'
            p.yaxis.major_label_text_font_size = '12pt'

            
            vline = Span(location=0, dimension='height', 
                         line_color='gray', line_width=1.5,
                         line_dash='dashed')
            p.renderers.extend([vline])

            if spinflag:
                p.line('en', 'up',   line_width = 2, line_color = 'blue',
                       legend="Spin Up",   source=source)
                p.line('en', 'down', line_width = 2, line_color = 'orange', 
                       legend="Spin Down", source=source)
            else:
                p.line('en', 'dos',  line_width = 2, line_color = 'blue',
                       legend='total',       source=source)

            p.legend.click_policy = "hide"
            self._bokeh_plot = p

        return self._bokeh_plot 
开发者ID:wolverton-research-group,项目名称:qmpy,代码行数:55,代码来源:dos.py

示例6: plotRSI

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Span [as 别名]
def plotRSI(p, df, plotwidth=800, upcolor='green',
            downcolor='red', yloc='right', limits=(30, 70)):
    # create y axis for rsi
    p.extra_y_ranges = {"rsi": Range1d(start=0, end=100)}
    p.add_layout(LinearAxis(y_range_name="rsi"), yloc)

    p.add_layout(Span(location=limits[0],
                      dimension='width',
                      line_color=upcolor,
                      line_dash='dashed',
                      line_width=2,
                      y_range_name="rsi"))

    p.add_layout(Span(location=limits[1],
                      dimension='width',
                      line_color=downcolor,
                      line_dash='dashed',
                      line_width=2,
                      y_range_name="rsi"))

    candleWidth = (df.iloc[2]['date'].timestamp() -
                   df.iloc[1]['date'].timestamp()) * plotwidth
    # plot green bars
    inc = df.rsi >= 50
    p.vbar(x=df.date[inc],
           width=candleWidth,
           top=df.rsi[inc],
           bottom=50,
           fill_color=upcolor,
           line_color=upcolor,
           alpha=0.5,
           y_range_name="rsi")
    # Plot red bars
    dec = df.rsi <= 50
    p.vbar(x=df.date[dec],
           width=candleWidth,
           top=50,
           bottom=df.rsi[dec],
           fill_color=downcolor,
           line_color=downcolor,
           alpha=0.5,
           y_range_name="rsi") 
开发者ID:s4w3d0ff,项目名称:marconibot,代码行数:44,代码来源:__init__.py

示例7: trial_viewer

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Span [as 别名]
def trial_viewer(step_data, roll_type = "ewm", roll_span=100, bar=False):
    """
    Args:
        step_data:
        grad_data:
    """
    step_data.loc[step_data['response'] == 'L','response'] = 0
    step_data.loc[step_data['response'] == 'R','response'] = 1
    step_data.loc[step_data['target'] == 'L','target'] = 0
    step_data.loc[step_data['target'] == 'R','target'] = 1

    palette = [cc.rainbow[i] for i in range(len(step_data['subject'].unique()))]
    palette = [cc.rainbow[i*15] for i in range(5)]

    mice = sorted(step_data['subject'].unique())
    current_step = step_data.groupby('subject').last().reset_index()
    current_step = current_step[['subject','step']]

    plots = []
    p = figure(x_range=step_data['subject'].unique(),title='Subject Steps',
               plot_height=200)
    p.xaxis.major_label_orientation = np.pi / 2
    p.vbar(x=current_step['subject'], top=current_step['step'], width=0.9)
    plots.append(p)
    for i, (mus, group) in enumerate(step_data.groupby('subject')):
        if roll_type == "ewm":
            meancx = group['correct'].ewm(span=roll_span,ignore_na=True).mean()
        else:
            meancx = group['correct'].rolling(window=roll_span).mean()

        title_str = "{}, step: {}".format(mus, group.step.iloc[-1])

        p = figure(plot_height=100,y_range=(0,1),title=title_str)

        if bar:
            hline = Span(location=bar, dimension="width", line_color='red', line_width=1)
            p.renderers.append(hline)

        p.line(group['trial_num'], meancx, color=palette[group['step'].iloc[0]-1])
        plots.append(p)
    grid = gridplot(plots, ncols=1)
    show(grid) 
开发者ID:wehr-lab,项目名称:autopilot,代码行数:44,代码来源:trial_viewer.py

示例8: show

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Span [as 别名]
def show(self, title='', xlabel='', ylabel='', xaxis=True, yaxis=True, xticks=True, yticks=True, legend=True, grid=True, **kwargs):
        # self.figure.add_tools(*[HoverTool(
        #     tooltips=[('x', '@x{%F}'), ('y', '@y')],
        #     formatters={'x': 'datetime'},
        #     mode='vline'
        # ) for _ in data])

        self.figure.outline_line_color = None
        # vline = Span(location=0, dimension='height', line_color='red', line_width=3)
        hline = Span(location=0, dimension='width', line_color='black', line_width=1)
        self.figure.renderers.append(hline)

        if xlabel:
            self.figure.xaxis.axis_label = kwargs.get('xlabel')
        if ylabel:
            self.figure.yaxis.axis_label = kwargs.get('ylabel')
        if title:
            self.figure.title.text = kwargs.get('title')

        if legend:
            self.figure.legend.location = (self.width + 10, self.height + 10)
            legend = Legend(items=self.legend, location=(10, 100))
            legend.items = self.legend
            legend.click_policy = "mute"
            self.figure.add_layout(legend, 'right')
        else:
            self.figure.legend.location = None

        if not grid:
            self.figure.xgrid.grid_line_color = None
            self.figure.ygrid.grid_line_color = None

        # FIXME
        if not yaxis:
            for ax in self.figure.yaxis:
                ax.axis_line_color = 'white'
        if not xaxis:
            for ax in self.figure.xaxis:
                ax.axis_line_color = 'white'

        # Turn off labels:
        # self.figure.xaxis.major_label_text_font_size = '0pt'

        show(self.figure)
        return self.figure 
开发者ID:timkpaine,项目名称:lantern,代码行数:47,代码来源:plot_bokeh.py


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