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 _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 _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 get_plot_component(self): xbounds = self.model.xh[0] / 1000, self.model.xh[-1] / 1000 ybounds = self.model.yh[0] / 1000, self.model.yh[-1] / 1000 self.plotdata.set_data("imagedata", self.model.Z) #self.plot.x_mapper.stretch_data = False #self.plot.y_mapper.stretch_data = False cmap = TransformColorMapper.from_color_map(jet) renderer = self.plot.img_plot("imagedata", xbounds = xbounds, ybounds = ybounds, colormap=cmap)[0] left = PlotAxis(orientation='left', title='km', mapper=self.plot.value_mapper, component=self.plot) bottom = PlotAxis(orientation='bottom', title='km', mapper=self.plot.index_mapper, component=self.plot) self.plot.underlays.append(left) self.plot.underlays.append(bottom) return self.plot
def get_plot_component(self): xbounds = self.model.xh[0] / 1000, self.model.xh[-1] / 1000 ybounds = self.model.yh[0] / 1000, self.model.yh[-1] / 1000 self.plotdata.set_data("imagedata", self.model.Z) #self.plot.x_mapper.stretch_data = False #self.plot.y_mapper.stretch_data = False cmap = TransformColorMapper.from_color_map(jet) renderer = self.plot.img_plot("imagedata", xbounds=xbounds, ybounds=ybounds, colormap=cmap)[0] left = PlotAxis(orientation='left', title='km', mapper=self.plot.value_mapper, component=self.plot) bottom = PlotAxis(orientation='bottom', title='km', mapper=self.plot.index_mapper, component=self.plot) self.plot.underlays.append(left) self.plot.underlays.append(bottom) return self.plot