def _plot_default(self): plot = Plot(self.plot_data) plot.x_axis = None plot.y_axis = None plot.x_grid = None plot.y_grid = None plot.padding = 0 plot.plot(('x', 'image_histogram'), render_style='connectedhold') plot.plot(('x', 'mapped_histogram'), type='filled_line', fill_color='yellow', render_style='connectedhold', name='mapped_histogram') intercept_tool = AttributeDragTool(component=plot, model=self.unit_map, x_attr='intercept') slope_tool = AttributeDragTool(component=plot, model=self.unit_map, x_attr='slope', modifier_keys=set(['shift'])) gamma_tool = AttributeDragTool(component=plot, model=self.unit_map, x_attr='gamma', modifier_keys=set(['control'])) plot.tools += [intercept_tool, slope_tool, gamma_tool] intercept_overlay = SimpleInspectorOverlay(component=plot, align='ul', inspector=intercept_tool, field_formatters=[[basic_formatter('Intercept', 2)]] ) slope_overlay = SimpleInspectorOverlay(component=plot, align='ul', inspector=slope_tool, field_formatters=[[basic_formatter('Slope', 2)]] ) gamma_overlay = SimpleInspectorOverlay(component=plot, align='ul', inspector=gamma_tool, field_formatters=[[basic_formatter('Gamma', 2)]] ) plot.overlays += [intercept_overlay, slope_overlay, gamma_overlay] return plot
def _create_returns_plot(self): plot = Plot(self.plotdata) plot.legend.visible = True #FIXME: The legend move tool doesn't seem to quite work right now #plot.legend.tools.append(LegendTool(plot.legend)) 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=tuple(COLOR_PALETTE[i]))[0] # 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 _plot_default(self): plot = Plot(self.plot_data) plot.x_axis = None plot.y_axis = None plot.padding = 0 self.tcm = TransformColorMapper.from_color_map(gray) self.tcm.unit_func = self.unit_map.function self.unit_map.on_trait_change(self.map_changed, 'function') plot.img_plot('image', colormap=self.tcm) return plot
def _plot_default(self): plot = Plot(self.plot_data) plot.x_axis = None plot.y_axis = None plot.x_grid = None plot.y_grid = None plot.padding = 0 plot.plot('image_histogram') plot.plot('mapped_histogram', type='filled_line', fill_color='yellow') return plot
def _plot_default(self): plot = Plot(self.plot_data) plot.x_axis = None plot.y_axis = None plot.x_grid = None plot.y_grid = None plot.padding = 0 plot.plot(('x', 'image_histogram'), render_style='connectedhold') plot.plot(('x', 'mapped_histogram'), type='filled_line', fill_color='yellow', render_style='connectedhold', name='mapped_histogram') intercept_tool = AttributeDragTool(component=plot, model=self.unit_map, x_attr='intercept') plot.tools.append(intercept_tool) return plot
def _main_plot_default(self): p = Plot(self.plot_data, default_origin='top left') p.padding = 0 self.original_plot = p.img_plot('original_image', colormap=bone, alpha=self.original_alpha, bgcolor=self.background_color_)[0] self.canny_plot = p.img_plot('canny_plot_image', alpha=self.canny_alpha)[0] p.x_axis = None p.y_axis = None self.segments_overlay = SegmentsOverlay(component=self.canny_plot, image_size=self.image.canny_image.shape) p.overlays.append(self.segments_overlay) return p
def _main_plot_default(self): p = Plot(self.plot_data, default_origin='top left') p.padding = 0 self.original_plot = p.img_plot('original_image', colormap=bone, alpha=self.original_alpha, bgcolor=self.background_color_)[0] self.canny_plot = p.img_plot('canny_plot_image', alpha=self.canny_alpha)[0] p.x_axis = None p.y_axis = None self.segments_overlay = SegmentsOverlay( component=self.canny_plot, image_size=self.image.canny_image.shape) p.overlays.append(self.segments_overlay) return p
def _create_returns_plot(self): plot = Plot(self.plotdata) plot.legend.visible = True #FIXME: The legend move tool doesn't seem to quite work right now #plot.legend.tools.append(LegendTool(plot.legend)) 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=tuple(COLOR_PALETTE[i]))[0] # 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", restrict_to_data=True)) plot.overlays.append( ZoomTool(plot, tool_mode="range", max_zoom_out=1.0, x_min_zoom_factor=float(1e-3))) # 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_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 _plot_default(self): plot = Plot(self.plot_data) plot.x_axis = None plot.y_axis = None plot.x_grid = None plot.y_grid = None plot.padding = 0 plot.plot(("x", "image_histogram"), render_style="connectedhold") plot.plot( ("x", "mapped_histogram"), type="filled_line", fill_color="yellow", render_style="connectedhold", name="mapped_histogram", ) low_overlay = AttributeLineOverlay(component=plot, model=self.unit_map, x_attr="low", orientation="vertical") high_overlay = AttributeLineOverlay(component=plot, model=self.unit_map, x_attr="high", orientation="vertical") intercept_tool = AttributeDragTool(component=plot, model=self.unit_map, x_attr="intercept") slope_tool = AttributeDragTool( component=plot, model=self.unit_map, x_attr="slope", modifier_keys=set(["shift"]) ) gamma_tool = AttributeDragTool( component=plot, model=self.unit_map, x_attr="gamma", modifier_keys=set(["control"]) ) plot.tools += [intercept_tool, slope_tool, gamma_tool] intercept_overlay = SimpleInspectorOverlay( component=plot, align="ul", inspector=intercept_tool, field_formatters=[[basic_formatter("Intercept", 2)]] ) slope_overlay = SimpleInspectorOverlay( component=plot, align="ul", inspector=slope_tool, field_formatters=[[basic_formatter("Slope", 2)]] ) gamma_overlay = SimpleInspectorOverlay( component=plot, align="ul", inspector=gamma_tool, field_formatters=[[basic_formatter("Gamma", 2)]] ) plot.overlays += [intercept_overlay, slope_overlay, gamma_overlay, low_overlay, high_overlay] return plot
def _create_plot_component(): army_lat = np.column_stack([army['start_lat'], army['end_lat']]).reshape(-1) army_lon = np.column_stack([army['start_lon'], army['end_lon']]).reshape(-1) plot_data = ArrayPlotData( army_lon=army_lon, army_lat=army_lat, army_size=army['size'], army_color=army['direction'] * army["group"], towns_lat=towns['lat'], towns_lon=towns['lon'], towns=towns['town'], temp_lon=temperatures['lon'], temp=temperatures['temp'], temp_date=temperatures['date'], ) map_plot = Plot(plot_data) map_plot.x_grid = None map_plot.y_grid = None map_plot.x_axis.orientation = 'top' map_plot.x_axis.title = 'Longitude' map_plot.y_axis.title = 'Latitude' map_plot.title = "Minard's Map of Napoleon's Russian Campaign" map_plot._title.overlay_position = "inside top" map_plot._title.hjustify = "left" map_plot._title.vjustify = "bottom" map_plot.plot( ("army_lon", "army_lat", "army_color", "army_size"), type="cmap_segment", name="my_plot", color_mapper=viridis, border_visible=True, bgcolor="white", size_min=1.0, size_max=128.0, ) map_plot.plot( ("towns_lon", "towns_lat"), type="scatter", ) map_plot.plot( ("towns_lon", "towns_lat", "towns"), type="text", text_margin=4, h_position='right', text_offset=(4, 0), ) map_plot.plot_1d( ('temp_lon'), type='line_scatter_1d', alpha=0.5, line_style='dot', ) map_plot.index_range.high_setting = 38 map_plot.index_range.low_setting = 23 map_plot.value_range.high_setting = 56.0 map_plot.value_range.low_setting = 53.5 map_plot.tools.extend([ PanTool(map_plot), ZoomTool(map_plot), ]) temp_plot = Plot(plot_data, height=100) temp_plot.index_range = map_plot.index_range temp_plot.x_grid = None temp_plot.x_axis = None temp_plot.y_axis.orientation = 'right' temp_plot.y_axis.title = u'Temp (°Re)' temp_plot.plot( ('temp_lon', 'temp'), type='line', ) temp_plot.plot_1d( ('temp_lon'), type='line_scatter_1d', alpha=0.5, line_style='dot', ) temp_plot.plot_1d( ('temp_lon', 'temp_date'), type='textplot_1d', alpha=0.5, line_style='dot', alignment='bottom', ) temp_plot.value_range.high_setting = 5 temp_plot.value_range.low_setting = -35 container = VPlotContainer(temp_plot, map_plot) container.spacing = 0 map_plot.padding_bottom = 0 map_plot.padding_left = 70 map_plot.padding_right = 70 map_plot.padding_top = 50 temp_plot.padding_top = 0 temp_plot.padding_bottom = 15 temp_plot.padding_right = 70 temp_plot.padding_left = 70 temp_plot.height = 100 temp_plot.resizable = 'h' return container
def _plot(self, x, y, z, scale): pd = ArrayPlotData() # pd.set_data("imagedata", z) plot = Plot(pd, padding_left=60, fill_padding=True) plot.bgcolor = 'white' cmap = fix(jet, (0, z.max())) plot.default_origin = 'bottom left' # origin = 'top left' # to flip y-axis fid = FunctionImageData(func=self._prepare_data_for_window, data_range=plot.range2d) pd.set_data("imagedata", fid) self.img_plot = plot.img_plot("imagedata", name="surface2d", xbounds=(np.min(x), np.max(x)), ybounds=(1.0, y[-1,-1]), colormap=cmap, hide_grids=True, interpolation='nearest' # origin=origin, )[0] #plot.default_origin = origin plot.x_axis = MyPlotAxis(component=plot, orientation='bottom') plot.y_axis = MyPlotAxis(component=plot, orientation='left') plot.x_axis.title = u'Angle (2\u0398)' tick_font = settings.tick_font plot.x_axis.title_font = settings.axis_title_font plot.y_axis.title_font = settings.axis_title_font plot.x_axis.tick_label_font = tick_font plot.y_axis.tick_label_font = tick_font plot.y_axis.title = "Dataset" # if <10 datasets we want to reduce down the tickmarks to multiples if len(y)<10: plot.y_axis.tick_interval = 1.0 else: plot.y_axis.tick_interval = len(y)/10 actual_plot = plot.plots["surface2d"][0] self.plot_zoom_tool = ClickUndoZoomTool( plot, always_on=True, pointer="cross", tool_mode="range", axis="index", drag_button=settings.zoom_button, undo_button=settings.undo_button, x_min_zoom_factor=-np.inf, y_min_zoom_factor=-np.inf, ) plot.overlays.append(self.plot_zoom_tool) plot.tools.append(TraitsTool(plot)) # Add a color bar colormap = actual_plot.color_mapper colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range), color_mapper=colormap, plot=actual_plot, orientation='v', resizable='v', width=30, padding=40, padding_top=50, fill_padding=True) colorbar._axis.title_font = settings.axis_title_font colorbar._axis.tick_label_font = settings.tick_font # Add pan and zoom tools to the colorbar self.colorbar_zoom_tool = ClickUndoZoomTool(colorbar, axis="index", tool_mode="range", always_on=True, drag_button=settings.zoom_button, undo_button=settings.undo_button) pan_tool = PanToolWithHistory(colorbar, history_tool=self.colorbar_zoom_tool, constrain_direction="y", constrain=True, drag_button=settings.pan_button) colorbar.tools.append(pan_tool) colorbar.overlays.append(self.colorbar_zoom_tool) # Add a label to the top of the color bar colorbar_label = PlotLabel( u'Intensity\n{:^9}'.format('(' + get_value_scale_label(scale) + ')'), component=colorbar, font=settings.axis_title_font, ) colorbar.overlays.append(colorbar_label) colorbar.tools.append(TraitsTool(colorbar)) # Add the plot and colorbar side-by-side container = HPlotContainer(use_backbuffer=True) container.add(plot) container.add(colorbar) self.twod_plot = plot return container
def _plot(self, x, y, z, scale): pd = ArrayPlotData() # pd.set_data("imagedata", z) plot = Plot(pd, padding_left=60, fill_padding=True) plot.bgcolor = 'white' cmap = fix(jet, (0, z.max())) plot.default_origin = 'bottom left' # origin = 'top left' # to flip y-axis fid = FunctionImageData(func=self._prepare_data_for_window, data_range=plot.range2d) pd.set_data("imagedata", fid) self.img_plot = plot.img_plot("imagedata", name="surface2d", xbounds=(np.min(x), np.max(x)), ybounds=(1.0, y[-1, -1]), colormap=cmap, hide_grids=True, interpolation='nearest' # origin=origin, )[0] #plot.default_origin = origin plot.x_axis = MyPlotAxis(component=plot, orientation='bottom') plot.y_axis = MyPlotAxis(component=plot, orientation='left') plot.x_axis.title = u'Angle (2\u0398)' tick_font = settings.tick_font plot.x_axis.title_font = settings.axis_title_font plot.y_axis.title_font = settings.axis_title_font plot.x_axis.tick_label_font = tick_font plot.y_axis.tick_label_font = tick_font plot.y_axis.title = "Dataset" # if <10 datasets we want to reduce down the tickmarks to multiples if len(y) < 10: plot.y_axis.tick_interval = 1.0 else: plot.y_axis.tick_interval = len(y) / 10 actual_plot = plot.plots["surface2d"][0] self.plot_zoom_tool = ClickUndoZoomTool( plot, always_on=True, pointer="cross", tool_mode="range", axis="index", drag_button=settings.zoom_button, undo_button=settings.undo_button, x_min_zoom_factor=-np.inf, y_min_zoom_factor=-np.inf, ) plot.overlays.append(self.plot_zoom_tool) plot.tools.append(TraitsTool(plot)) # Add a color bar colormap = actual_plot.color_mapper colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range), color_mapper=colormap, plot=actual_plot, orientation='v', resizable='v', width=30, padding=40, padding_top=50, fill_padding=True) colorbar._axis.title_font = settings.axis_title_font colorbar._axis.tick_label_font = settings.tick_font # Add pan and zoom tools to the colorbar self.colorbar_zoom_tool = ClickUndoZoomTool( colorbar, axis="index", tool_mode="range", always_on=True, drag_button=settings.zoom_button, undo_button=settings.undo_button) pan_tool = PanToolWithHistory(colorbar, history_tool=self.colorbar_zoom_tool, constrain_direction="y", constrain=True, drag_button=settings.pan_button) colorbar.tools.append(pan_tool) colorbar.overlays.append(self.colorbar_zoom_tool) # Add a label to the top of the color bar colorbar_label = PlotLabel( u'Intensity\n{:^9}'.format('(' + get_value_scale_label(scale) + ')'), component=colorbar, font=settings.axis_title_font, ) colorbar.overlays.append(colorbar_label) colorbar.tools.append(TraitsTool(colorbar)) # Add the plot and colorbar side-by-side container = HPlotContainer(use_backbuffer=True) container.add(plot) container.add(colorbar) self.twod_plot = plot return container