def _create_barplots(self): # Get the size of each individual bin bin_width = self.bar_width / self.nbvars barplots = [] for (i, v) in zip(self.indices, self.values): index = ArrayDataSource(i) index_range = DataRange1D(index, low= -0.5, high=self.nbdata + 0.5, tight_bounds=True) index_mapper = LinearMapper(range=index_range) # value = ArrayDataSource(v) value_range = DataRange1D(value, tight_bounds=True) value_mapper = LinearMapper(range=value_range) barplot = BarPlot(index=index, index_mapper=index_mapper, value=value, value_mapper=value_mapper, line_color=0x111111, labels=self.labels, bar_width=bin_width, antialias=True) barplot.padding = 30 barplots.append(barplot) self.barplots = barplots return barplots
def __init__(self, link): super(TrackingView, self).__init__() self.link = link self.link.add_callback(MSG_TRACKING_SNRS, self.tracking_snrs_callback) # ======= Line Plot ======= self.plot_data = ArrayPlotData(t=[0.0]) self.plot = Plot(self.plot_data, auto_colors=colours_list) self.plot.value_range.tight_bounds = False self.plot.value_range.low_setting = 0.0 for n in range(TRACK_N_CHANNELS): self.plot_data.set_data('ch'+str(n), [0.0]) self.plot.plot(('t', 'ch'+str(n)), type='line', color='auto') # ======= Bar Plot ======= idxs = ArrayDataSource(range(1, len(self.snrs)+1)) self.vals = ArrayDataSource(self.snrs, sort_order='none') # Create the index range index_range = DataRange1D(idxs, low=0.4, high=TRACK_N_CHANNELS+0.6) index_mapper = LinearMapper(range=index_range) # Create the value range value_range = DataRange1D(low=0.0, high=25.0) value_mapper = LinearMapper(range=value_range) plot = BarPlot(index=idxs, value=self.vals, index_mapper=index_mapper, value_mapper=value_mapper, line_color='blue', fill_color='blue', bar_width=0.8) container = OverlayPlotContainer(bgcolor = "white") plot.padding = 10 plot.padding_left = 30 plot.padding_bottom = 30 container.add(plot) left_axis = PlotAxis(plot, orientation='left') bottom_axis = LabelAxis(plot, orientation='bottom', labels = map(str, range(1, TRACK_N_CHANNELS+1)), positions = range(1, TRACK_N_CHANNELS+1), small_haxis_style=True) plot.underlays.append(left_axis) plot.underlays.append(bottom_axis) self.snr_bars = container self.python_console_cmds = { 'track': self }