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


Python models.Range1d方法代码示例

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


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

示例1: create

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def create(self):
        self.source = self.update_source()

        max_data = max(max(self.source.data['relevant']), max(self.source.data['crawled']))
        xdr = Range1d(start=0, end=max_data)

        p = figure(plot_width=400, plot_height=400,
                   title="Domains Sorted by %s" % self.sort, x_range = xdr,
                   y_range = FactorRange(factors=self.source.data['domain']),
                   tools='reset, resize, save')

        p.rect(y='domain', x='crawled_half', width="crawled", height=0.75,
               color=DARK_GRAY, source =self.source, legend="crawled")
        p.rect(y='domain', x='relevant_half', width="relevant", height=0.75,
               color=GREEN, source =self.source, legend="relevant")

        p.ygrid.grid_line_color = None
        p.xgrid.grid_line_color = '#8592A0'
        p.axis.major_label_text_font_size = "8pt"

        script, div = components(p)

        if os.path.exists(self.crawled_data) and os.path.exists(self.relevant_data):
            return (script, div) 
开发者ID:nasa-jpl-memex,项目名称:memex-explorer,代码行数:26,代码来源:domain.py

示例2: test_points_errorbars_text_ndoverlay_categorical_xaxis

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def test_points_errorbars_text_ndoverlay_categorical_xaxis(self):
        overlay = NdOverlay({i: Points(([chr(65+i)]*10,np.random.randn(10)))
                             for i in range(5)})
        error = ErrorBars([(el['x'][0], np.mean(el['y']), np.std(el['y']))
                           for el in overlay])
        text = Text('C', 0, 'Test')
        plot = bokeh_renderer.get_plot(overlay*error*text)
        x_range = plot.handles['x_range']
        y_range = plot.handles['y_range']
        self.assertIsInstance(x_range, FactorRange)
        factors = ['A', 'B', 'C', 'D', 'E']
        self.assertEqual(x_range.factors, ['A', 'B', 'C', 'D', 'E'])
        self.assertIsInstance(y_range, Range1d)
        error_plot = plot.subplots[('ErrorBars', 'I')]
        for xs, factor in zip(error_plot.handles['source'].data['base'], factors):
            self.assertEqual(factor, xs) 
开发者ID:holoviz,项目名称:holoviews,代码行数:18,代码来源:testoverlayplot.py

示例3: create_bar_plot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def create_bar_plot(init_data, title):
    init_data = downsample(init_data, 50)
    x = range(len(init_data))
    source = ColumnDataSource(data=dict(x= [], y=[]))
    fig = figure(title=title, plot_width=300, plot_height=300)
    fig.vbar(x=x, width=1, top=init_data, fill_alpha=0.05)
    fig.vbar('x', width=1, top='y', fill_alpha=0.3, source=source)
    fig.y_range = Range1d(min(0, 1.2 * min(init_data)), 1.2 * max(init_data))
    return fig, source 
开发者ID:MarcusOlivecrona,项目名称:REINVENT,代码行数:11,代码来源:main.py

示例4: legend

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def legend():
    # Set ranges
    xdr = Range1d(0, 100)
    ydr = Range1d(0, 500)
    # Create plot
    plot = Plot(
        x_range=xdr,
        y_range=ydr,
        title="",
        plot_width=100,
        plot_height=500,
        min_border=0,
        toolbar_location=None,
        outline_line_color="#FFFFFF",
    )

    # For each color in your palette, add a Rect glyph to the plot with the appropriate properties
    palette = RdBu11
    width = 40
    for i, color in enumerate(palette):
        rect = Rect(
            x=40, y=(width * (i + 1)),
            width=width, height=40,
            fill_color=color, line_color='black'
        )
        plot.add_glyph(rect)

    # Add text labels and add them to the plot
    minimum = Text(x=50, y=0, text=['-6 ºC'])
    plot.add_glyph(minimum)
    maximum = Text(x=50, y=460, text=['6 ºC'])
    plot.add_glyph(maximum)

    return plot 
开发者ID:chdoig,项目名称:scipy2015-blaze-bokeh,代码行数:36,代码来源:viz2.py

示例5: plotCCI

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def plotCCI(p, df, plotwidth=800, upcolor='orange', downcolor='yellow'):
    # create y axis for rsi
    p.extra_y_ranges = {"cci": Range1d(start=min(df['cci'].values),
                                       end=max(df['cci'].values))}
    p.add_layout(LinearAxis(y_range_name="cci"), 'right')
    candleWidth = (df.iloc[2]['date'].timestamp() -
                   df.iloc[1]['date'].timestamp()) * plotwidth
    # plot green bars
    inc = df.cci >= 0
    p.vbar(x=df.date[inc],
           width=candleWidth,
           top=df.cci[inc],
           bottom=0,
           fill_color=upcolor,
           line_color=upcolor,
           alpha=0.5,
           y_range_name="cci",
           legend='cci')
    # Plot red bars
    dec = df.cci < 0
    p.vbar(x=df.date[dec],
           width=candleWidth,
           top=0,
           bottom=df.cci[dec],
           fill_color=downcolor,
           line_color=downcolor,
           alpha=0.5,
           y_range_name="cci",
           legend='cci') 
开发者ID:s4w3d0ff,项目名称:marconibot,代码行数:31,代码来源:__init__.py

示例6: plotVolume

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def plotVolume(p, df, plotwidth=800, upcolor='green',
               downcolor='red', colname='volume'):
    candleWidth = (df.iloc[2]['date'].timestamp() -
                   df.iloc[1]['date'].timestamp()) * plotwidth
    # create new y axis for volume
    p.extra_y_ranges = {colname: Range1d(start=min(df[colname].values),
                                         end=max(df[colname].values))}
    p.add_layout(LinearAxis(y_range_name=colname), 'right')
    # Plot green candles
    inc = df.close > df.open
    p.vbar(x=df.date[inc],
           width=candleWidth,
           top=df[colname][inc],
           bottom=0,
           alpha=0.1,
           fill_color=upcolor,
           line_color=upcolor,
           y_range_name=colname)

    # Plot red candles
    dec = df.open > df.close
    p.vbar(x=df.date[dec],
           width=candleWidth,
           top=df[colname][dec],
           bottom=0,
           alpha=0.1,
           fill_color=downcolor,
           line_color=downcolor,
           y_range_name=colname) 
开发者ID:s4w3d0ff,项目名称:marconibot,代码行数:31,代码来源:__init__.py

示例7: init_plot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def init_plot(crawl_name):
    session = Session()
    document = Document()
    session.use_doc(crawl_name)
    session.load_document(document)

    if document.context.children:
        plot = document.context.children[0]
    else:
        output_server(crawl_name)
        # TODO: Remove these when Bokeh is upgraded
        # placeholders or Bokeh can't inject properly
        current = np.datetime64(datetime.now())
        xdr = Range1d(current, current + 1)
        ydr = ["urls"]

        # styling suggested by Bryan
        plot = figure(title="Crawler Monitor", tools="hover",
                      x_axis_type="datetime", y_axis_location="right", x_range=xdr, y_range=ydr,
                      width=1200, height=600)
        plot.toolbar_location = None
        plot.xgrid.grid_line_color = None

        # temporarily turn these off
        plot.ygrid.grid_line_color = None
        plot.xaxis.minor_tick_line_color = None
        plot.xaxis.major_tick_line_color = None
        plot.xaxis.major_label_text_font_size = '0pt'
        plot.yaxis.minor_tick_line_color = None
        plot.yaxis.major_tick_line_color = None
        plot.yaxis.major_label_text_font_size = '0pt'

    document.add(plot)
    session.store_document(document)
    script = autoload_server(plot, session)

    #TODO: Looks like a Bokeh bug, probably not repeatable with current code
    script = script.replace("'modelid': u'", "'modelid': '")
    return script 
开发者ID:nasa-jpl-memex,项目名称:memex-explorer,代码行数:41,代码来源:stream.py

示例8: utilization_bar

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def utilization_bar(max_y):
    plot = Figure(plot_width = 150, # this is more for the ratio, because we have auto-width scaling
                  plot_height = 150,
                  tools = [], # no tools needed for this one
                  title = 'Utilization')
    plot.toolbar.logo = None  # hides logo
    plot.x_range = Range1d(0, 1) 
    plot.y_range = Range1d(0, max_y)  # sometimes you want it to be way less than 1, to see it move
    plot.xaxis.visible = False # hide x axis
    # Add input buffer
    manager = Manager()
    plot._input_buffer = manager.dict()
    return plot 
开发者ID:pysdr,项目名称:pysdr,代码行数:15,代码来源:gui.py

示例9: test_server_callback_resolve_attr_spec_range1d_start

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def test_server_callback_resolve_attr_spec_range1d_start(self):
        range1d = Range1d(start=0, end=10)
        msg = Callback.resolve_attr_spec('x_range.attributes.start', range1d)
        self.assertEqual(msg, {'id': range1d.ref['id'], 'value': 0}) 
开发者ID:holoviz,项目名称:holoviews,代码行数:6,代码来源:testcallbacks.py

示例10: test_server_callback_resolve_attr_spec_range1d_end

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def test_server_callback_resolve_attr_spec_range1d_end(self):
        range1d = Range1d(start=0, end=10)
        msg = Callback.resolve_attr_spec('x_range.attributes.end', range1d)
        self.assertEqual(msg, {'id': range1d.ref['id'], 'value': 10}) 
开发者ID:holoviz,项目名称:holoviews,代码行数:6,代码来源:testcallbacks.py

示例11: test_points_errorbars_text_ndoverlay_categorical_xaxis_invert_axes

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def test_points_errorbars_text_ndoverlay_categorical_xaxis_invert_axes(self):
        overlay = NdOverlay({i: Points(([chr(65+i)]*10,np.random.randn(10)))
                             for i in range(5)})
        error = ErrorBars([(el['x'][0], np.mean(el['y']), np.std(el['y']))
                           for el in overlay]).opts(plot=dict(invert_axes=True))
        text = Text('C', 0, 'Test')
        plot = bokeh_renderer.get_plot(overlay*error*text)
        x_range = plot.handles['x_range']
        y_range = plot.handles['y_range']
        self.assertIsInstance(x_range, Range1d)
        self.assertIsInstance(y_range, FactorRange)
        self.assertEqual(y_range.factors, ['A', 'B', 'C', 'D', 'E']) 
开发者ID:holoviz,项目名称:holoviews,代码行数:14,代码来源:testoverlayplot.py

示例12: test_heatmap_categorical_axes_string_int

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def test_heatmap_categorical_axes_string_int(self):
        hmap = HeatMap([('A', 1, 1), ('B', 2, 2)])
        plot = bokeh_renderer.get_plot(hmap)
        x_range = plot.handles['x_range']
        y_range = plot.handles['y_range']
        self.assertIsInstance(x_range, FactorRange)
        self.assertEqual(x_range.factors, ['A', 'B'])
        self.assertIsInstance(y_range, Range1d)
        self.assertEqual(y_range.start, 0.5)
        self.assertEqual(y_range.end, 2.5) 
开发者ID:holoviz,项目名称:holoviews,代码行数:12,代码来源:testheatmapplot.py

示例13: test_heatmap_categorical_axes_string_int_inverted

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def test_heatmap_categorical_axes_string_int_inverted(self):
        hmap = HeatMap([('A',1, 1), ('B', 2, 2)]).opts(invert_axes=True)
        plot = bokeh_renderer.get_plot(hmap)
        x_range = plot.handles['x_range']
        y_range = plot.handles['y_range']
        self.assertIsInstance(x_range, Range1d)
        self.assertEqual(x_range.start, 0.5)
        self.assertEqual(x_range.end, 2.5)
        self.assertIsInstance(y_range, FactorRange)
        self.assertEqual(y_range.factors, ['A', 'B']) 
开发者ID:holoviz,项目名称:holoviews,代码行数:12,代码来源:testheatmapplot.py

示例14: test_heatmap_points_categorical_axes_string_int

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def test_heatmap_points_categorical_axes_string_int(self):
        hmap = HeatMap([('A', 1, 1), ('B', 2, 2)])
        points = Points([('A', 2), ('B', 1),  ('C', 3)])
        plot = bokeh_renderer.get_plot(hmap*points)
        x_range = plot.handles['x_range']
        y_range = plot.handles['y_range']
        self.assertIsInstance(x_range, FactorRange)
        self.assertEqual(x_range.factors, ['A', 'B', 'C'])
        self.assertIsInstance(y_range, Range1d)
        self.assertEqual(y_range.start, 0.5)
        self.assertEqual(y_range.end, 3) 
开发者ID:holoviz,项目名称:holoviews,代码行数:13,代码来源:testheatmapplot.py

示例15: test_heatmap_points_categorical_axes_string_int_inverted

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import Range1d [as 别名]
def test_heatmap_points_categorical_axes_string_int_inverted(self):
        hmap = HeatMap([('A',1, 1), ('B', 2, 2)]).opts(invert_axes=True)
        points = Points([('A', 2), ('B', 1),  ('C', 3)])
        plot = bokeh_renderer.get_plot(hmap*points)
        x_range = plot.handles['x_range']
        y_range = plot.handles['y_range']
        self.assertIsInstance(x_range, Range1d)
        self.assertEqual(x_range.start, 0.5)
        self.assertEqual(x_range.end, 3)
        self.assertIsInstance(y_range, FactorRange)
        self.assertEqual(y_range.factors, ['A', 'B', 'C']) 
开发者ID:holoviz,项目名称:holoviews,代码行数:13,代码来源:testheatmapplot.py


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