def __init__(self, *args, **kwargs): super(DemoView, self).__init__(*args, **kwargs) # Create the plot object, set some options, and add some tools plot = self.plot = Plot(self.pd, default_origin="top left") plot.x_axis.orientation = "top" plot.padding = 50 plot.padding_top = 75 plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) # Load the default image self._load() # Plot the image plot with this image self.plot.img_plot("imagedata")
def add_line(self, str_x, str_y, x1, y1, x2, y2, color1): """ drawline draws 1 line on the screen by using lineplot x1,y1->x2,y2 parameters: str_x - label of x coordinate str_y - label of y coordinate x1,y1,x2,y2 - start and end coordinates of the line color1 - color of the line example usage: drawline("x_coord","y_coord",100,100,200,200,red) draws a red line 100,100->200,200 """ # self._plot_data.set_data(str_x,[x1,x2]) # self._plot_data.set_data(str_y,[y1,y2]) self._plot_data.set_data(str_x, [x1, x2]) self._plot_data.set_data(str_y, [y1, y2]) self._plot.add(Plot((str_x, str_y), type="line", color=color1))
def _create_xy8_plot(self): plot_data_xy8_line = ArrayPlotData(counts2=np.array((0., 1.)), time=np.array((0., 0.)), fit=np.array((0., 0.))) plot = Plot(plot_data_xy8_line, width=50, height=40, padding=8, padding_left=64, padding_bottom=32) plot.plot(('time', 'counts2'), color='green', line_width=2) plot.index_axis.title = 'time [ns]' plot.value_axis.title = 'counts' #plot.title='counts' self.plot_data_xy8_line = plot_data_xy8_line self.xy8_plot = plot return self.xy8_plot
def _create_returns_plot(self): plot = Plot(self.plotdata) plot.legend.visible = False plot.x_axis = None x_axis = PlotAxis( plot, orientation="bottom", tick_generator=ScalesTickGenerator(scale=CalendarScaleSystem())) plot.overlays.append(x_axis) plot.x_grid.tick_generator = x_axis.tick_generator for i, name in enumerate(self.plotdata.list_data()): if name == "times": continue renderer = plot.plot(("times", name), type="line", name=name, color="auto", line_width=2)[0] self.times_ds = renderer.index print('chaco: %s') % str(time.time() - tic) # Tricky: need to set auto_handle_event on the RangeSelection # so that it passes left-clicks to the PanTool # FIXME: The range selection is still getting the initial left down renderer.tools.append( RangeSelection(renderer, left_button_selects=False, auto_handle_event=False)) plot.tools.append( PanTool(plot, drag_button="left", constrain=True, constrain_direction="x")) plot.overlays.append( ZoomTool(plot, tool_mode="range", max_zoom_out=1.0)) # Attach the range selection to the last renderer; any one will do self._range_selection_overlay = RangeSelectionOverlay( renderer, metadata_name="selections") renderer.overlays.append(self._range_selection_overlay) # Grab a reference to the Time axis datasource and add a listener to its # selections metadata self.times_ds = renderer.index self.times_ds.on_trait_change(self._selections_changed, 'metadata_changed') self.returns_plot = plot
def _create_digits_plot(self): data = ArrayPlotData(image=numpy.zeros((2, 2))) plot = Plot(data, width=500, height=500, resizable='hv', aspect_ratio=37.0 / 9, padding=8, padding_left=48, padding_bottom=36) plot.img_plot('image', xbounds=(0, 1), ybounds=(0, 1), colormap=hot) plot.plots['plot0'][0].value_range.high_setting = 1 plot.plots['plot0'][0].value_range.low_setting = 0 plot.x_axis = None plot.y_axis = None self.digits_data = data self.digits_plot = plot
def create_plot(): numpoints = 100 low = -5 high = 15.0 x = linspace(low, high, numpoints) pd = ArrayPlotData(index=x) p = Plot(pd, bgcolor="oldlace", padding=50, border_visible=True) for i in range(10): pd.set_data("y" + str(i), jn(i, x)) p.plot(("index", "y" + str(i)), color=tuple(COLOR_PALETTE[i]), width=2.0 * dpi_scale) p.x_grid.visible = True p.x_grid.line_width *= dpi_scale p.y_grid.visible = True p.y_grid.line_width *= dpi_scale p.legend.visible = True return p
def _create_temperature_plot(self): plot_data = ArrayPlotData(time=np.array((0., 1.)), temperature=np.array((0., 40.)), fit=np.array((0., 0.))) plot = Plot(plot_data, width=50, height=40, padding=8, padding_left=64, padding_bottom=32) plot.plot(('time', 'temperature'), color='green') plot.index_axis.title = 'time [h]' plot.value_axis.title = 'temperature [C]' self.plot_data = plot_data self.temperature_plot = plot return self.temperature_plot
def _plot_default(self): # Create the data and the PlotData object x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x=x, y=y) # Create a Plot and associate it with the PlotData plot = Plot(plotdata) # Create a scatter plot in the Plot plot.plot(("x", "y"), type="scatter", color="blue") plot.tools.append(PanTool(plot)) # Add our custom overlay to the plot overlay = CustomOverlay(plot) # Add the MoveTool to the overlay so it can be dragged around usin gthe # right mouse button. overlay.tools.append(MoveTool(overlay, drag_button="right")) plot.overlays.append(overlay) return plot
def create_plot(): numpoints = 100 low = -5 high = 15.0 x = linspace(low, high, numpoints) pd = ArrayPlotData(index=x) p = Plot(pd, bgcolor="lightgray", padding=50, border_visible=True) for t,i in sm.zip(cycle(['line','scatter']),sm.range(10)): pd.set_data("y" + str(i), jn(i,x)) p.plot(("index", "y" + str(i)), color=tuple(COLOR_PALETTE[i]), width = 2.0 * dpi_scale, type=t) p.x_grid.visible = True p.x_grid.line_width *= dpi_scale p.y_grid.visible = True p.y_grid.line_width *= dpi_scale p.legend.visible = True return p
def __init__(self, **kw): super(WorldMapPlot, self).__init__(**kw) self._download_map_image() image = ImageData.fromfile(self.image_path) # For now, the locations are hardcoded, though this can be changed # eassily to take command line args, read from a file, or by other # means austin_loc = (30.16, -97.44) locations_x = numpy.array([austin_loc[1]]) locations_y = numpy.array([austin_loc[0]]) # transform each of the locations to the image data space, including # moving the origin from bottom left to top left locations_x = (locations_x + 180) * image.data.shape[1] / 360 locations_y = (locations_y * -1 + 90) * image.data.shape[0] / 180 # Create the plott data, adding the image and the locations plot_data = ArrayPlotData() plot_data.set_data("imagedata", image._data) plot_data.set_data("locations_x", locations_x) plot_data.set_data("locations_y", locations_y) # Create the plot with the origin as top left, which matches # how the image data is aligned self.plot = Plot(plot_data, default_origin="top left") self.plot.img_plot('imagedata') # Plot the locations as a scatter plot to be overlayed on top # of the map loc_plot = self.plot.plot(('locations_x', 'locations_y'), type='scatter', size=3, color='yellow', marker='dot')[0] loc_plot.x_mapper.range.high = image.data.shape[1] loc_plot.x_mapper.range.low = 0 loc_plot.y_mapper.range.high = image.data.shape[0] loc_plot.y_mapper.range.low = -0 # set up any tools, in this case just the zoom tool zoom = ZoomTool(component=self.plot, tool_mode="box", always_on=False) self.plot.overlays.append(zoom)
def _create_plot_component(model): # Create a plot data object and give it the model's data array. pd = ArrayPlotData() pd.set_data("imagedata", model.data) # Create the "main" Plot. plot = Plot(pd, padding=50) # Use a TransformColorMapper for the color map. tcm = TransformColorMapper.from_color_map(jet) # Create the image plot renderer in the main plot. renderer = plot.img_plot("imagedata", xbounds=model.x_array, ybounds=model.y_array, colormap=tcm)[0] # Create the colorbar. lm = LinearMapper(range=renderer.value_range, domain_limits=(renderer.value_range.low, renderer.value_range.high)) colorbar = ColorBar(index_mapper=lm, plot=plot, orientation='v', resizable='v', width=30, padding=20) colorbar.padding_top = plot.padding_top colorbar.padding_bottom = plot.padding_bottom # Add pan and zoom tools to the colorbar. colorbar.tools.append(PanTool(colorbar, constrain_direction="y", constrain=True)) zoom_overlay = ZoomTool(colorbar, axis="index", tool_mode="range", always_on=True, drag_button="right") colorbar.overlays.append(zoom_overlay) # Create a container to position the plot and the colorbar side-by-side container = HPlotContainer(use_backbuffer = True) container.add(plot) container.add(colorbar) return container
def _bar_default(self): index = np.arange(0, len(self.current_weight)) bar_data = ArrayPlotData(index=index, value=self.current_weight) self.bar_data = bar_data bar = Plot(data=bar_data) bar.plot(('index', 'value'), type='bar', bar_width=0.8, color='auto') label_axis = LabelAxis(bar, orientation='bottom', title='components', tick_interval=1, positions=index, labels=self.header, small_haxis_style=True) bar.underlays.remove(bar.index_axis) bar.index_axis = label_axis bar.range2d.y_range.high = 1.0 return bar
def _create_plot_component(self): plot_data = TableModelPlotData(model = self.model) self.component = plot = Plot(plot_data, auto_axis = False, padding_left = 75, # FIXME: Can Chaco calcuate this automatically? ) plot.x_axis = DropAxis(component = plot, mapper = plot.x_mapper, plot_name = 'x', orientation = 'bottom') plot.y_axis = DropAxis(component = plot, mapper = plot.y_mapper, plot_name = 'y', orientation = 'left') self.scatter = scatter = plot.plot(('x', 'y'), type = 'scatter', marker = 'circle', )[0] plot.title = self.settings.title # Create selection overlay. inspector_overlay = SafeScatterInspectorOverlay(self.model, scatter, selection_metadata_name = 'selection', selection_color = 'blue', selection_marker_size = 6, ) scatter.overlays.append(inspector_overlay) # Create standard tools (always active). scatter.tools.append(PanTool(scatter, drag_button = 'right')) self._zoom_tool = ZoomTool(scatter, drag_button=None, enter_zoom_key=KeySpec(None), exit_zoom_key=KeySpec(None) ) scatter.tools.append(self._zoom_tool) # Create the active selection and tool. self._set_selection(self.selected) self._set_tool(self.tool) # Register event handlers. scatter.index.on_trait_change(self._update_selection, 'metadata_changed')
def __init__(self, index, series_a, series_b, series_c, **kw): super(PlotExample, self).__init__(**kw) plot_data = ArrayPlotData(index=index) starting_values = np.ones(10) * 0.5 starting_vals = ArrayDataSource(starting_values, sort_order="none") series_a = series_a + starting_values plot_data.set_data('series_a', series_a) plot_data.set_data('series_b', series_b) plot_data.set_data('series_c', series_c) self.plot = Plot(plot_data) self.plot.plot(('index', 'series_a'), type='bar', bar_width=0.8, color='auto', starting_value=starting_vals) # set the plot's value range to 0, otherwise it may pad too much self.plot.value_range.low = 0 tick_positions_and_labels = { x: 'label_{}'.format(x) for x in range(1, 11) } tick_generator = ShowAllTickGenerator( positions=tick_positions_and_labels.keys()) def formatter(value): return tick_positions_and_labels[int(value)] plot_axis = PlotAxis( component=self.plot, mapper=self.plot.x_mapper, # labels=labels, orientation='bottom', tick_generator=tick_generator, tick_label_rotate_angle=-45., tick_label_alignment='corner', tick_label_formatter=formatter, tick_label_offset=3) self.plot.underlays.remove(self.plot.index_axis) self.plot.index_axis = plot_axis self.plot.overlays.append(plot_axis)
def _create_plot_component(): # Create some data npts = 2000 x = sort(random(npts)) y = random(npts) # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) # Create the plot plot = Plot(pd) plot.plot(("index", "value"), type="scatter", name="my_plot", marker="circle", index_sort="ascending", color="red", marker_size=4, bgcolor="white") # Tweak some of the plot properties plot.title = "Scatter Plot With Lasso Selection" plot.line_width = 1 plot.padding = 50 # Right now, some of the tools are a little invasive, and we need the # actual ScatterPlot object to give to them my_plot = plot.plots["my_plot"][0] # Attach some tools to the plot lasso_selection = LassoSelection(component=my_plot, selection_datasource=my_plot.index) my_plot.active_tool = lasso_selection my_plot.tools.append(ScatterInspector(my_plot)) lasso_overlay = LassoOverlay(lasso_selection=lasso_selection, component=my_plot) my_plot.overlays.append(lasso_overlay) # Uncomment this if you would like to see incremental updates: #lasso_selection.incremental_select = True return plot
def _add_new_plot(self, new_data): code = self.data_provider.code if code in self.dataset.list_data(): create_new_plot = False else: create_new_plot = True self.dataset.set_data(code, new_data) if create_new_plot: new_plot = Plot(self.dataset) new_plot.plot(('dates', code), type='line') tick_generator = ScalesTickGenerator(scale=CalendarScaleSystem()) new_plot.x_axis.tick_generator = tick_generator self.container.add(new_plot) self.container.request_redraw()
def __init__(self): # Create the data and the PlotData object. For a 2D plot, we need to # take the row of X points and Y points and create a grid from them # using meshgrid(). x = linspace(0, 8, 50) y = linspace(0, 6, 50) xgrid, ygrid = meshgrid(x, y) z = exp(-(xgrid * xgrid + ygrid * ygrid) / 100) plotdata = ArrayPlotData(imagedata=z) # Create a Plot and associate it with the PlotData plot = Plot(plotdata) # Create an image plot in the Plot self.renderer = plot.img_plot("imagedata", name="plot1", xbounds=xgrid, ybounds=ygrid, colormap=jet)[0] self.plot = plot
def _plot_default(self, toolbar=True, **pltkwds): ''' Draw bare plot, including main plotting area, toolbar, etc... either at initialization or global redo''' if toolbar: self.plot = ToolbarPlot(self.plotdata, **pltkwds) else: self.plot = Plot(self.plotdata, **pltkwds) self.plot.title = self.title self.plot.padding = 50 self.plot.legend.visible = False self.plot.tools.append(PanTool(self.plot)) zoom = BetterSelectingZoom(component=self.plot, tool_mode="box", always_on=False) self.plot.overlays.append(zoom)
def _create_filter_function_plot(self): plot_data_filter_function = ArrayPlotData(freq=np.array((0., 1.)), value=np.array((0., 0.)), fit=np.array((0., 0.))) plot = Plot(plot_data_filter_function, width=50, height=40, padding=8, padding_left=64, padding_bottom=32) plot.plot(('freq', 'value'), color='red', type='line', line_width=3) plot.index_axis.title = 'frequency [MHz]' plot.value_axis.title = 'Filter Function Fourier Transform' #plot.title='Fourier transform of filter function' self.plot_data_filter_function = plot_data_filter_function self.filter_function_plot = plot return self.filter_function_plot
def _creat_line_plot(self): line_data = ArrayPlotData(frequency=self.freq, counts=np.mean(self.matrix, 0)) line_plot = Plot(line_data, padding=8, padding_left=64, padding_bottom=32) line_plot.plot(('frequency', 'counts'), style='line', color='blue') line_plot.index_axis.title = 'Frequency [MHz]' line_plot.value_axis.title = 'Fluorescence counts' line_label = PlotLabel(text='', hjustify='left', vjustify='bottom', position=[64, 128]) line_plot.overlays.append(line_label) self.line_label = line_label self.line_data = line_data self.line_plot = line_plot
def test_draw_border_simple(self): """ Borders should have the correct height and width. """ size = (5,5) container = Plot(padding=1, border_visible=True) container.outer_bounds = list(size) gc = PlotGraphicsContext(size) gc.render_component(container) desired = array(((255, 255, 255, 255, 255, 255), (255, 0, 0, 0, 0, 255), (255, 0, 255, 255, 0, 255), (255, 0, 255, 255, 0, 255), (255, 0, 0, 0, 0, 255), (255, 255, 255, 255, 255, 255))) actual = gc.bmp_array[:,:,0] self.assertRavelEqual(actual, desired)
def _create_plot_component(): red = util.Color(255, 0, 0, 255) green = util.Color(0, 255, 0, 255) blue = util.Color(0, 0, 255, 255) purple = util.Color(125, 0, 255, 255) white = util.Color(255, 255, 255, 255) black = util.Color(0, 0, 0, 255) shape = glyphset.ShapeCodes.RECT glyphs = blzg.load_csv( "../data/circlepoints.csv", "x", "y", "series", schema="{r:float32, theta:float32, x:float32, y:float32, series:int32}" ) screen = (800, 600) ivt = util.zoom_fit(screen, glyphs.bounds()) with Timer("Abstract-Render") as arTimer: image = core.render( glyphs, infos.val(), blzg.CountCategories("int32"), categories.HDAlpha([red, blue, green, purple, black]), screen, ivt) # image = core.render(glyphs, # infos.valAt(4,0), # blzg.Count(), # numeric.BinarySegment(white, black, 1), # screen, # ivt) # Create a plot data object and give it this data pd = ArrayPlotData() pd.set_data("imagedata", image) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata")[0] # Tweak some of the plot properties plot.title = "Abstract Rendering" plot.padding = 50 return plot
def plot_robot(self): plot = Plot(self.plot_data) plot.range2d.x_range = self.x_range plot.range2d.y_range = self.y_range plot.x_mapper = LinearMapper(range=self.x_range) plot.y_mapper = LinearMapper(range=self.y_range) plot.title = "robot" plot.plot(('robot_x', 'robot_y'), type='polygon', marker='dot', marker_size=1.0, color=(0, 0, 0, 0.8)) wheel_outline_color = (0, 0, 0, 1.0) wheel_color = (0, 0, 0, 0.8) plot.plot(('wheel_bl_x', 'wheel_bl_y'), type='polygon', marker='dot', marker_size=1.0, face_color=wheel_color, color=wheel_outline_color) plot.plot(('wheel_br_x', 'wheel_br_y'), type='polygon', marker='dot', marker_size=1.0, face_color=wheel_color, color=wheel_outline_color) plot.plot(('wheel_tr_x', 'wheel_tr_y'), type='polygon', marker='dot', marker_size=1.0, face_color=wheel_color, color=wheel_outline_color) plot.plot(('wheel_tl_x', 'wheel_tl_y'), type='polygon', marker='dot', marker_size=1.0, face_color=wheel_color, color=wheel_outline_color) return plot
def _load_image(self, path): self.container = self._container_factory() im = Image.open(path) # oim = array(im) im = im.convert('L') odim = ndim = array(im) # if self.contrast_equalize: # ndim = self._contrast_equalize(ndim) # self._ndim = ndim # low = self.low # high = self.high # if self.use_threshold: # tim = zeros_like(ndim) # tim[where((ndim > low) & (ndim < high))] = 255 # self.area = (sum(tim) / (ndim.shape[0] * ndim.shape[1])) / 255. # else: # tim = ndim pd = ArrayPlotData() pd.set_data('img', odim) plot = Plot(data=pd, padding=[30, 5, 5, 30], default_origin='top left') img_plot = plot.img_plot('img', colormap=color_map_name_dict[self.colormap_name_1] )[0] self.add_inspector(img_plot) self.add_tools(img_plot) self.oplot = plot # pd = ArrayPlotData() # pd.set_data('img', tim) # plot = Plot(data=pd, # padding=[30, 5, 5, 30], default_origin='top left') # img_plot = plot.img_plot('img', colormap=color_map_name_dict[self.colormap_name_2])[0] # self.add_inspector(img_plot) # self.plot = plot # # self.plot.range2d = self.oplot.range2d self.container.add(self.oplot) # self.container.add(self.plot) self.container.request_redraw()
def __init__(self, link): super(BaselineView, self).__init__() self.log_file = None self.num_hyps = 0 self.plot_data = ArrayPlotData(n=[0.0], e=[0.0], d=[0.0], t=[0.0], ref_n=[0.0], ref_e=[0.0], ref_d=[0.0]) self.plot = Plot(self.plot_data) self.plot.plot(('e', 'n'), type='line', name='line', color=(0, 0, 0, 0.1)) self.plot.plot(('e', 'n'), type='scatter', name='points', color='blue', marker='dot', line_width=0.0, marker_size=1.0) self.plot.plot(('ref_e', 'ref_n'), type='scatter', color='red', marker='plus', marker_size=5, line_width=1.5 ) self.plot.index_axis.tick_label_position = 'inside' self.plot.index_axis.tick_label_color = 'gray' self.plot.index_axis.tick_color = 'gray' self.plot.value_axis.tick_label_position = 'inside' self.plot.value_axis.tick_label_color = 'gray' self.plot.value_axis.tick_color = 'gray' self.plot.padding = (0, 1, 0, 1) self.plot.tools.append(PanTool(self.plot)) zt = ZoomTool(self.plot, zoom_factor=1.1, tool_mode="box", always_on=False) self.plot.overlays.append(zt) self.week = None self.nsec = 0 self.link = link self.link.add_callback(sbp_messages.SBP_BASELINE_NED, self._baseline_callback_ned) self.link.add_callback(sbp_messages.SBP_BASELINE_ECEF, self._baseline_callback_ecef) self.link.add_callback(sbp_messages.IAR_STATE, self.iar_state_callback) self.link.add_callback(sbp_messages.SBP_GPS_TIME, self.gps_time_callback) self.python_console_cmds = { 'baseline': self }
def __init__(self, link): super(MagView, self).__init__() self.mag = np.zeros((NUM_POINTS, 3)) self.plot_data = ArrayPlotData(t=np.arange(NUM_POINTS), mag_x=[0.0], mag_y=[0.0], mag_z=[0.0]) self.plot = Plot(self.plot_data, auto_colors=colours_list, emphasized=True) self.plot.title = 'Raw Magnetometer Data' self.plot.title_color = [0, 0, 0.43] self.plot.value_axis.orientation = 'right' self.plot.value_axis.axis_line_visible = False call_repeatedly(0.2, self.mag_set_data) self.legend_visible = True self.plot.legend.visible = True self.plot.legend.align = 'll' self.plot.legend.line_spacing = 1 self.plot.legend.font = 'modern 8' self.plot.legend.draw_layer = 'overlay' self.plot.legend.tools.append( LegendTool(self.plot.legend, drag_button="right")) mag_x = self.plot.plot(('t', 'mag_x'), type='line', color='auto', name='Mag. X (uT)') mag_y = self.plot.plot(('t', 'mag_y'), type='line', color='auto', name='Mag. Y (uT)') mag_z = self.plot.plot(('t', 'mag_z'), type='line', color='auto', name='Mag. Z (uT)') self.link = link self.link.add_callback(self.mag_raw_callback, SBP_MSG_MAG_RAW) self.python_console_cmds = {'track': self}
def plot_factory(legend_kw=None, **kw): """ """ p = Plot(data=ArrayPlotData(), **kw) vis = kw['show_legend'] if 'show_legend' in kw else False if not isinstance(vis, bool): align = vis vis = True else: align = 'lr' p.legend.visible = vis p.legend.align = align if legend_kw: p.legend.trait_set(**legend_kw) return p
def test_bounds_2d_case(): # test for bug: contour and image plots should support the case where # xbounds and ybounds are 2d arrays resulting from meshgrids xs = np.linspace(-10, 10, 200) ys = np.linspace(-10, 10, 400) x, y = np.meshgrid(xs, ys) z = x + y plotdata = ArrayPlotData() plotdata.set_data("z", z) plot = Plot(plotdata) plot.contour_plot("z", xbounds=x, ybounds=y) # try to display it, that's when the exception is raised with store_exceptions_on_all_threads(): pv = PlotViewer(plot=plot) pv.edit_traits()
def __init__(self, link, legend_visible=True): super(TrackingView, self).__init__() self._at_least_one_track_received = False self.t_init = monotonic() self.time = deque([x * 1 / TRK_RATE for x in range(-NUM_POINTS, 0, 1)], maxlen=NUM_POINTS) self.CN0_lock = threading.Lock() self.CN0_dict = defaultdict( lambda: deque([0] * NUM_POINTS, maxlen=NUM_POINTS)) self.CN0_age = defaultdict(lambda: -1) self.sv_labels = [] self.glo_fcn_dict = {} self.glo_slot_dict = {} self.n_channels = None self.plot_data = ArrayPlotData(t=[0.0]) self.plot = Plot(self.plot_data, emphasized=True) self.plot.title = 'Tracking C/N0' self.plot.title_color = [0, 0, 0.43] self.ylim = self.plot.value_mapper.range self.ylim.low = SNR_THRESHOLD self.ylim.high = 60 self.plot.value_range.bounds_func = lambda l, h, m, tb: (0, h * (1 + m)) self.plot.value_axis.orientation = 'right' self.plot.value_axis.axis_line_visible = False self.plot.value_axis.title = 'dB-Hz' self.plot_data.set_data('t', self.time) self.plot.index_axis.title = 'seconds' self.legend_visible = True self.plot.legend.visible = legend_visible self.plot.legend.align = 'll' self.plot.legend.line_spacing = 1 self.plot.legend.font = 'monospace 8' self.plot.legend.draw_layer = 'overlay' self.plot.legend.tools.append( LegendTool(self.plot.legend, drag_button="right")) self.link = link self.link.add_callback(self.measurement_state_callback, SBP_MSG_MEASUREMENT_STATE) self.link.add_callback(self.tracking_state_callback, SBP_MSG_TRACKING_STATE) self.python_console_cmds = {'track': self} self.update_scheduler = UpdateScheduler()
def _create_plot_component(): # make 10 random points x = arange(10) x = ArrayDataSource(x, sort_order="ascending") y = random_sample(10) # Plot the data pd = ArrayPlotData(x=x, y=y) plot = Plot(pd) plot.orientation = 'v' line_plot = plot.plot(("x", "y"))[0] # Add the tool to the plot both as a tool and as an overlay tool = HittestTool(component=plot, line_plot=line_plot) plot.tools.append(tool) plot.overlays.append(tool) return plot