Python bokeh.models.FactorRange() Examples
The following are 17
code examples of bokeh.models.FactorRange().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
bokeh.models
, or try the search function
.
Example #1
Source File: domain.py From memex-explorer with BSD 2-Clause "Simplified" License | 6 votes |
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)
Example #2
Source File: testoverlayplot.py From holoviews with BSD 3-Clause "New" or "Revised" License | 6 votes |
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)
Example #3
Source File: test_image.py From PyBloqs with GNU Lesser General Public License v2.1 | 6 votes |
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)
Example #4
Source File: testpointplot.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
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'])
Example #5
Source File: testheatmapplot.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
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'])
Example #6
Source File: testheatmapplot.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #7
Source File: testheatmapplot.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
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'])
Example #8
Source File: testheatmapplot.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #9
Source File: testpointplot.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
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'])
Example #10
Source File: testpointplot.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
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])
Example #11
Source File: testpointplot.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
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'])
Example #12
Source File: testpointplot.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
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'])
Example #13
Source File: testoverlayplot.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
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'])
Example #14
Source File: testcurveplot.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
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'])
Example #15
Source File: testcurveplot.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
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'])
Example #16
Source File: NeoPredViz.py From NeoPredPipe with GNU Lesser General Public License v3.0 | 4 votes |
def SummaryBarChart(self): self.summaryData.sort_values(by=['Total'], inplace=True) self.summaryData.reset_index(drop=True, inplace=True) # Get factors for each Sample factors = [] shared = [] clonal = [] subclonal = [] self.summaryData.rename(index=self.summaryData.Sample, inplace=True) for sam in self.summaryData.Sample: factors.append( (sam,"Total") ) clonal.append(self.summaryData.loc[sam,'Clonal']) subclonal.append(self.summaryData.loc[sam,'Subclonal']) shared.append(self.summaryData.loc[sam,'Shared']) factors.append( (sam,"WB") ) clonal.append(self.summaryData.loc[sam,'Clonal_WB']) subclonal.append(self.summaryData.loc[sam,'Subclonal_WB']) shared.append(self.summaryData.loc[sam,'Shared_WB']) factors.append( (sam,"SB") ) clonal.append(self.summaryData.loc[sam,'Clonal_SB']) subclonal.append(self.summaryData.loc[sam,'Subclonal_SB']) shared.append(self.summaryData.loc[sam,'Shared_SB']) clonality = ['clonal','subclonal','shared'] source = ColumnDataSource(data=dict( x=factors, clonal=clonal, subclonal=subclonal, shared=shared )) TOOLTIPS = [('Clonal', '@clonal'), ('Subclonal', '@subclonal'), ('Shared', '@shared')] p = figure(x_range=FactorRange(*factors), tooltips=TOOLTIPS, height=400) clonalityColors = ["#00a4ed","#ef4f25","#ede614"] p.vbar_stack(clonality, x='x',width=0.9,color=clonalityColors, source=source, legend=[value(x) for x in clonality]) p.xaxis.major_label_orientation = np.pi / 2 p.xaxis.group_label_orientation = np.pi / 2 p.legend.orientation = "horizontal" p.legend.location = "top_center" p.xgrid.grid_line_color = None p.ygrid.grid_line_color = None p.xaxis.major_tick_line_color = None p.yaxis.axis_label="Neoantigens" p.x_range.range_padding = 0.1 return(p)
Example #17
Source File: whisker_quantiles.py From CAVE with BSD 3-Clause "New" or "Revised" License | 4 votes |
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