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


Python models.FactorRange方法代碼示例

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


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

示例1: test_bokehplot

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import FactorRange [as 別名]
def test_bokehplot():
    fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
    years = ['2015', '2016', '2017']

    data = {'fruits': fruits,
            '2015': [2, 1, 4, 3, 2, 4],
            '2016': [5, 3, 3, 2, 4, 6],
            '2017': [3, 2, 4, 4, 5, 3]}

    x = [(fruit, year) for fruit in fruits for year in years]
    counts = sum(zip(data['2015'], data['2016'], data['2017']), ())  # like an hstack

    source = ColumnDataSource(data=dict(x=x, counts=counts))

    fig = figure(x_range=FactorRange(*x), plot_height=350, title="Fruit Counts by Year",
                 toolbar_location=None, tools="")
    fig.vbar(x='x', top='counts', width=0.9, source=source)
    return BokehPlotBlock(fig) 
開發者ID:man-group,項目名稱:PyBloqs,代碼行數:20,代碼來源:test_image.py

示例2: create

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import FactorRange [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

示例3: test_points_errorbars_text_ndoverlay_categorical_xaxis

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import FactorRange [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

示例4: test_curve_categorical_xaxis

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import FactorRange [as 別名]
def test_curve_categorical_xaxis(self):
        curve = Curve((['A', 'B', 'C'], [1,2,3]))
        plot = bokeh_renderer.get_plot(curve)
        x_range = plot.handles['x_range']
        self.assertIsInstance(x_range, FactorRange)
        self.assertEqual(x_range.factors, ['A', 'B', 'C']) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:8,代碼來源:testcurveplot.py

示例5: test_curve_categorical_xaxis_invert_axes

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import FactorRange [as 別名]
def test_curve_categorical_xaxis_invert_axes(self):
        curve = Curve((['A', 'B', 'C'], (1,2,3))).opts(plot=dict(invert_axes=True))
        plot = bokeh_renderer.get_plot(curve)
        y_range = plot.handles['y_range']
        self.assertIsInstance(y_range, FactorRange)
        self.assertEqual(y_range.factors, ['A', 'B', 'C']) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:8,代碼來源:testcurveplot.py

示例6: test_points_errorbars_text_ndoverlay_categorical_xaxis_invert_axes

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import FactorRange [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

示例7: test_points_categorical_xaxis

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import FactorRange [as 別名]
def test_points_categorical_xaxis(self):
        points = Points((['A', 'B', 'C'], (1,2,3)))
        plot = bokeh_renderer.get_plot(points)
        x_range = plot.handles['x_range']
        self.assertIsInstance(x_range, FactorRange)
        self.assertEqual(x_range.factors, ['A', 'B', 'C']) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:8,代碼來源:testpointplot.py

示例8: test_points_categorical_xaxis_invert_axes

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import FactorRange [as 別名]
def test_points_categorical_xaxis_invert_axes(self):
        points = Points((['A', 'B', 'C'], (1,2,3))).opts(plot=dict(invert_axes=True))
        plot = bokeh_renderer.get_plot(points)
        y_range = plot.handles['y_range']
        self.assertIsInstance(y_range, FactorRange)
        self.assertEqual(y_range.factors, ['A', 'B', 'C']) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:8,代碼來源:testpointplot.py

示例9: test_points_overlay_categorical_xaxis

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import FactorRange [as 別名]
def test_points_overlay_categorical_xaxis(self):
        points = Points((['A', 'B', 'C'], (1,2,3)))
        points2 = Points((['B', 'C', 'D'], (1,2,3)))
        plot = bokeh_renderer.get_plot(points*points2)
        x_range = plot.handles['x_range']
        self.assertIsInstance(x_range, FactorRange)
        self.assertEqual(x_range.factors, ['A', 'B', 'C', 'D']) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:9,代碼來源:testpointplot.py

示例10: test_points_overlay_categorical_xaxis_invert_axis

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import FactorRange [as 別名]
def test_points_overlay_categorical_xaxis_invert_axis(self):
        points = Points((['A', 'B', 'C'], (1,2,3))).opts(plot=dict(invert_xaxis=True))
        points2 = Points((['B', 'C', 'D'], (1,2,3)))
        plot = bokeh_renderer.get_plot(points*points2)
        x_range = plot.handles['x_range']
        self.assertIsInstance(x_range, FactorRange)
        self.assertEqual(x_range.factors, ['A', 'B', 'C', 'D'][::-1]) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:9,代碼來源:testpointplot.py

示例11: test_points_overlay_categorical_xaxis_invert_axes

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import FactorRange [as 別名]
def test_points_overlay_categorical_xaxis_invert_axes(self):
        points = Points((['A', 'B', 'C'], (1,2,3))).opts(plot=dict(invert_axes=True))
        points2 = Points((['B', 'C', 'D'], (1,2,3)))
        plot = bokeh_renderer.get_plot(points*points2)
        y_range = plot.handles['y_range']
        self.assertIsInstance(y_range, FactorRange)
        self.assertEqual(y_range.factors, ['A', 'B', 'C', 'D']) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:9,代碼來源:testpointplot.py

示例12: test_heatmap_categorical_axes_string_int

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