def __init__(self, depth, data_series, **kw): super(MyPlot, self).__init__(**kw) plot_data = ArrayPlotData(index=depth) plot_data.set_data('data_series', data_series) self.plot = Plot(plot_data, orientation='v', origin='top left') self.plot.plot(('index', 'data_series'))
def _create_plot_component():# Create a scalar field to colormap xbounds = (-2*pi, 2*pi, 600) ybounds = (-1.5*pi, 1.5*pi, 300) xs = linspace(*xbounds) ys = linspace(*ybounds) x, y = meshgrid(xs,ys) z = sin(x)*y # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("imagedata", z) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata", xbounds = xbounds[:2], ybounds = ybounds[:2], colormap=jet)[0] # Tweak some of the plot properties plot.title = "My First Image Plot" plot.padding = 50 # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) imgtool = ImageInspectorTool(img_plot) img_plot.tools.append(imgtool) overlay = ImageInspectorOverlay(component=img_plot, image_inspector=imgtool, bgcolor="white", border_visible=True) img_plot.overlays.append(overlay) return plot
def __init__(self, signal_instance): super(TemplatePicker, self).__init__() try: import cv except: print "OpenCV unavailable. Can't do cross correlation without it. Aborting." return None self.OK_custom = OK_custom_handler() self.sig = signal_instance if not hasattr(self.sig.mapped_parameters, "original_files"): self.sig.data = np.atleast_3d(self.sig.data) self.titles = [self.sig.mapped_parameters.name] else: self.numfiles = len( self.sig.mapped_parameters.original_files.keys()) self.titles = self.sig.mapped_parameters.original_files.keys() tmp_plot_data = ArrayPlotData( imagedata=self.sig.data[self.top:self.top + self.tmp_size, self.left:self.left + self.tmp_size, self.img_idx]) tmp_plot = Plot(tmp_plot_data, default_origin="top left") tmp_plot.img_plot("imagedata", colormap=jet) tmp_plot.aspect_ratio = 1.0 self.tmp_plot = tmp_plot self.tmp_plotdata = tmp_plot_data self.img_plotdata = ArrayPlotData( imagedata=self.sig.data[:, :, self.img_idx]) self.img_container = self._image_plot_container() self.crop_sig = None
class DataChooser(HasTraits): plot = Instance(Plot) data_name = Enum("jn0", "jn1", "jn2") traits_view = View(Item('data_name', label="Y data"), Item('plot', editor=ComponentEditor(), show_label=False), width=800, height=600, resizable=True, title="Data Chooser") def __init__(self): x = linspace(-5, 10, 100) self.data = {"jn0": jn(0, x), "jn1": jn(1, x), "jn2": jn(2, x)} # Create the data and the PlotData object self.plotdata = ArrayPlotData(x=x, y=self.data["jn0"]) # Create a Plot and associate it with the PlotData plot = Plot(self.plotdata) # Create a line plot in the Plot plot.plot(("x", "y"), type="line", color="blue") self.plot = plot def _data_name_changed(self, old, new): self.plotdata.set_data("y", self.data[self.data_name])
def __init__(self): # 首先需要调用父类的初始化函数 super(TriangleWave, self).__init__() # 创建绘图数据集,暂时没有数据因此都赋值为空,只是创建几个名字,以供Plot引用 self.plot_data = ArrayPlotData(x=[], y=[], f=[], p=[], x2=[], y2=[]) # 创建一个垂直排列的绘图容器,它将频谱图和波形图上下排列 self.container = VPlotContainer() # 创建波形图,波形图绘制两条曲线: 原始波形(x,y)和合成波形(x2,y2) self.plot_wave = self._create_plot(("x", "y"), "Triangle Wave") self.plot_wave.plot(("x2", "y2"), color="red") # 创建频谱图,使用数据集中的f和p self.plot_fft = self._create_plot(("f", "p"), "FFT", type="scatter") # 将两个绘图容器添加到垂直容器中 self.container.add(self.plot_wave) self.container.add(self.plot_fft) # 设置 self.plot_wave.x_axis.title = "Samples" self.plot_fft.x_axis.title = "Frequency pins" self.plot_fft.y_axis.title = "(dB)" # 改变fftsize为1024,因为Enum的默认缺省值为枚举列表中的第一个值 self.fftsize = 1024
def _create_plot_component(): # Create some data numpts = 5000 x = sort(random(numpts)) y = random(numpts) # 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", marker="circle", index_sort="ascending", color="orange", marker_size=3, bgcolor="white") # Tweak some of the plot properties plot.title = "Scatter Plot" plot.line_width = 0.5 plot.padding = 50 # Attach some tools to the plot plot.tools.append(PanTool(plot, constrain_key="shift")) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) return plot
def _create_plot_component(): # Create a GridContainer to hold all of our plots container = GridContainer(padding=20, fill_padding=True, bgcolor="lightgray", use_backbuffer=True, shape=(3,3), spacing=(12,12)) # Create the initial series of data x = linspace(-5, 15.0, 100) pd = ArrayPlotData(index = x) # Plot some bessel functions and add the plots to our container for i in range(9): pd.set_data("y" + str(i), jn(i,x)) plot = Plot(pd) plot.plot(("index", "y" + str(i)), color=tuple(COLOR_PALETTE[i]), line_width=2.0, bgcolor = "white", border_visible=True) # Tweak some of the plot properties plot.border_width = 1 plot.padding = 10 # Set each plot's aspect ratio based on its position in the # 3x3 grid of plots. n,m = divmod(i, 3) plot.aspect_ratio = float(n+1) / (m+1) # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) # Add to the grid container container.add(plot) return container
def _create_plot_component():# Create a scalar field to colormap xbounds = (-2*pi, 2*pi, 600) ybounds = (-1.5*pi, 1.5*pi, 300) xs = linspace(*xbounds) ys = linspace(*ybounds) x, y = meshgrid(xs,ys) z = sin(x)*y # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("imagedata", z) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata", xbounds=xbounds[:2], ybounds=ybounds[:2], colormap=jet)[0] # Tweak some of the plot properties plot.title = "Image Plot with Lasso" plot.padding = 50 lasso_selection = LassoSelection(component=img_plot) lasso_selection.on_trait_change(lasso_updated, "disjoint_selections") lasso_overlay = LassoOverlay(lasso_selection = lasso_selection, component=img_plot) img_plot.tools.append(lasso_selection) img_plot.overlays.append(lasso_overlay) return plot
def _create_plot_component(): # Create some x-y data series to plot x = linspace(-2.0, 10.0, 100) pd = ArrayPlotData(index = x) for i in range(5): pd.set_data("y" + str(i), jn(i,x)) # Create some line plots of some of the data plot1 = Plot(pd, padding=50) plot1.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red") plot1.plot(("index", "y3"), name="j_3", color="blue") # Attach some tools to the plot plot1.tools.append(PanTool(plot1)) zoom = ZoomTool(component=plot1, tool_mode="box", always_on=False) plot1.overlays.append(zoom) # Add the scrollbar hscrollbar = PlotScrollBar(component=plot1, axis="index", resizable="h", height=15) plot1.padding_top = 0 hscrollbar.force_data_update() # Create a container and add our plots container = VPlotContainer() container.add(plot1) container.add(hscrollbar) return container
def _create_plot_component(): # Create a scalar field to colormap xs = linspace(0, 10, 600) ys = linspace(0, 5, 600) x, y = meshgrid(xs, ys) z = exp(-(x**2 + y**2) / 100) # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("imagedata", z) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata", xbounds=(0, 10), ybounds=(0, 5), colormap=jet)[0] # Tweak some of the plot properties plot.title = "My First Image Plot" plot.padding = 50 # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=img_plot, tool_mode="box", always_on=False) img_plot.overlays.append(zoom) return plot
def __init__(self, index, data_series, **kw): super(MyPlot, self).__init__(**kw) plot_data = ArrayPlotData(index=index) plot_data.set_data('data_series', data_series) self.plot = Plot(plot_data) self.plot.plot(('index', 'data_series'))
def _create_plot_component(): # Create some RGBA image data image = zeros((200,400,4), dtype=uint8) image[:,0:40,0] += 255 # Vertical red stripe image[0:25,:,1] += 255 # Horizontal green stripe; also yellow square image[-80:,-160:,2] += 255 # Blue square image[:,:,3] = 255 # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("imagedata", image) # Create the plot plot = Plot(pd, default_origin="top left") plot.x_axis.orientation = "top" img_plot = plot.img_plot("imagedata")[0] # Tweak some of the plot properties plot.bgcolor = "white" # Attach some tools to the plot plot.tools.append(PanTool(plot, constrain_key="shift")) plot.overlays.append(ZoomTool(component=plot, tool_mode="box", always_on=False)) imgtool = ImageInspectorTool(img_plot) img_plot.tools.append(imgtool) plot.overlays.append(ImageInspectorOverlay(component=img_plot, image_inspector=imgtool)) return plot
def _create_plot_component(): # Create some x-y data series (with NaNs) to plot x = linspace(-5.0, 15.0, 500) x[75:125] = nan x[200:250] = nan x[300:330] = nan pd = ArrayPlotData(index = x) pd.set_data("value1", jn(0, x)) pd.set_data("value2", jn(1, x)) # Create some line and scatter plots of the data plot = Plot(pd) plot.plot(("index", "value1"), name="j_0(x)", color="red", width=2.0) plot.plot(("index", "value2"), type="scatter", marker_size=1, name="j_1(x)", color="green") # Tweak some of the plot properties plot.title = "Plots with NaNs" plot.padding = 50 plot.legend.visible = True # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) return plot
def _create_plot_component(): # Create some x-y data series to plot x = linspace(-2.0, 10.0, 100) pd = ArrayPlotData(index = x) for i in range(5): pd.set_data("y" + str(i), jn(i,x)) # Create some line plots of some of the data plot1 = Plot(pd, title="Line Plot", padding=50, border_visible=True) plot1.legend.visible = True plot1.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red") plot1.plot(("index", "y3"), name="j_3", color="blue") # Attach some tools to the plot plot1.tools.append(PanTool(plot1)) zoom = ZoomTool(component=plot1, tool_mode="box", always_on=False) plot1.overlays.append(zoom) # Create a second scatter plot of one of the datasets, linking its # range to the first plot plot2 = Plot(pd, range2d=plot1.range2d, title="Scatter plot", padding=50, border_visible=True) plot2.plot(('index', 'y3'), type="scatter", color="blue", marker="circle") # Create a container and add our plots container = HPlotContainer() container.add(plot1) container.add(plot2) return container
def _create_plot_component(): # Create some data numpts = 1000 x = sort(random(numpts)) y = random(numpts) color = exp(-(x**2 + y**2)) # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) pd.set_data("color", color) # Create the plot plot = Plot(pd) plot.plot(("index", "value", "color"), type="cmap_scatter", name="my_plot", color_mapper=jet, marker = "square", fill_alpha = 0.5, marker_size = 6, outline_color = "black", border_visible = True, bgcolor = "white") # Tweak some of the plot properties plot.title = "Colormapped Scatter Plot" plot.padding = 50 plot.x_grid.visible = False plot.y_grid.visible = False plot.x_axis.font = "modern 16" plot.y_axis.font = "modern 16" # Right now, some of the tools are a little invasive, and we need the # actual ColomappedScatterPlot object to give to them cmap_renderer = plot.plots["my_plot"][0] # Attach some tools to the plot plot.tools.append(PanTool(plot, constrain_key="shift")) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) selection = ColormappedSelectionOverlay(cmap_renderer, fade_alpha=0.35, selection_type="mask") cmap_renderer.overlays.append(selection) # Create the colorbar, handing in the appropriate range and colormap colorbar = create_colorbar(plot.color_mapper) colorbar.plot = cmap_renderer colorbar.padding_top = plot.padding_top colorbar.padding_bottom = plot.padding_bottom # Create a container to position the plot and the colorbar side-by-side container = HPlotContainer(use_backbuffer = True) container.add(plot) container.add(colorbar) container.bgcolor = "lightgray" return container
def __init__(self): super(EqualizerDesigner, self).__init__() self.plot_data = ArrayPlotData(f=FREQS, gain=[], phase=[]) self.plot_gain = self._create_plot(("f", "gain"), "Gain(dB)") self.plot_phase = self._create_plot(("f", "phase"), "Phase(degree)") self.container = VPlotContainer() self.container.add(self.plot_phase) self.container.add(self.plot_gain) self.plot_gain.padding_bottom = 20 self.plot_phase.padding_top = 20
def __init__(self, index, value, *args, **kw): super(PlotExample, self).__init__(*args, **kw) plot_data = ArrayPlotData(index=index) plot_data.set_data("value", value) self.plot = Plot(plot_data) line = self.plot.plot(("index", "value"))[0] line.overlays.append(XRayOverlay(line)) line.tools.append(BoxSelectTool(line))
def _create_plot_component(): # Create some data numpts = 1000 x = numpy.arange(0, numpts) y = numpy.random.random(numpts) marker_size = numpy.random.normal(4.0, 4.0, numpts) # Create a plot data object and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) # Because this is a non-standard renderer, we can't call plot.plot, which # sets up the array data sources, mappers and default index/value ranges. # So, its gotta be done manually for now. index_ds = ArrayDataSource(x) value_ds = ArrayDataSource(y) # Create the plot plot = Plot(pd) plot.index_range.add(index_ds) plot.value_range.add(value_ds) # Create the index and value mappers using the plot data ranges imapper = LinearMapper(range=plot.index_range) vmapper = LinearMapper(range=plot.value_range) # Create the scatter renderer scatter = VariableSizeScatterPlot( index=index_ds, value=value_ds, index_mapper = imapper, value_mapper = vmapper, marker='circle', marker_size=marker_size, color=(1.0,0.0,0.75,0.4)) # Append the renderer to the list of the plot's plots plot.add(scatter) plot.plots['var_size_scatter'] = [scatter] # Tweak some of the plot properties plot.title = "Scatter Plot" plot.line_width = 0.5 plot.padding = 50 # Attach some tools to the plot plot.tools.append(PanTool(plot, constrain_key="shift")) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) return plot
def _plot_default(self): outcomes, results, time = self._prepare_data() # get the x,y data to plot pds = [] for outcome in outcomes: pd = ArrayPlotData(index = time) result = results.get(outcome) for j in range(result.shape[0]): pd.set_data("y"+str(j), result[j, :] ) pds.append(pd) # Create a container and add our plots container = GridContainer( bgcolor="white", use_backbuffer=True, shape=(len(outcomes),1)) #plot data tools = [] for j, outcome in enumerate(outcomes): pd1 = pds[j] # Create some line plots of some of the data plot = Plot(pd1, title=outcome, border_visible=True, border_width = 1) plot.legend.visible = False a = len(pd1.arrays)- 1 if a > 1000: a = 1000 for i in range(a): plotvalue = "y"+str(i) color = colors[i%len(colors)] plot.plot(("index", plotvalue), name=plotvalue, color=color) for value in plot.plots.values(): for entry in value: entry.index.sort_order = 'ascending' # Attach the selector tools to the plot selectorTool1 = LineSelectorTool(component=plot) plot.tools.append(selectorTool1) tools.append(selectorTool1) container.add(plot) #make sure the selector tools know each other for tool in tools: a = set(tools) - set([tool]) tool._other_selectors = list(a) tool._demo = self return container
class LinePlot(QtGui.QWidget): def __init__(self, parent, title, x, y, xtitle, ytitle, type="line", color="blue"): QtGui.QWidget.__init__(self) # Create the subclass's window self.enable_win = self._create_window(title, x, y, xtitle, ytitle, type, color) layout = QtGui.QVBoxLayout() layout.setMargin(0) layout.addWidget(self.enable_win.control) self.setLayout(layout) self.resize(650,650) self.show() def _create_window(self, title, xtitle, x, ytitle, y, type="line", color="blue"): self.plotdata = ArrayPlotData(x=x, y=y) plot = ToolbarPlot(self.plotdata) plot.plot(('x', 'y'), type=type, color=color) plot.title = title plot.x_axis.title = xtitle plot.y_axis.title = ytitle self.plot = plot self._hid = 0 self._colors = ['blue', 'red', 'black', 'green', 'magenta', 'yellow'] # Add some tools self.plot.tools.append(PanTool(self.plot, constrain_key="shift")) self.plot.overlays.append(ZoomTool(component=self.plot, tool_mode="box", always_on=False)) return Window(self, -1, component=plot) def update_plot(self, x,y): ''' Update plot ''' self.plotdata.set_data('x', x) self.plotdata.set_data('y', y) self.plot.data = self.plotdata self.plot.request_redraw() def plot_hold_on(self, x, y, type="line"): ''' Plot if hold on ''' self._hid = self._hid + 1 self.plotdata.set_data('x' + str(self._hid), x) self.plotdata.set_data('y' + str(self._hid), y) self.plot.plot(('x' + str(self._hid), 'y' + str(self._hid)), type=type, color=self._colors[self._hid%len(self._colors)]) self.plot.request_redraw()
def create_plot(): # Create some data numpts = 200 x = sort(random(numpts)) y = random(numpts) color = exp(-(x**2 + y**2)) # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) pd.set_data("color", color) # Create the plot plot = Plot(pd) plot.plot(("index", "value", "color"), type="cmap_scatter", name="my_plot", color_mapper=jet, marker = "square", fill_alpha = 0.5, marker_size = 6, outline_color = "black", border_visible = True, bgcolor = "white") # Tweak some of the plot properties plot.title = "Colormapped Scatter Plot" plot.padding = 50 plot.x_grid.visible = False plot.y_grid.visible = False plot.x_axis.font = "modern 16" plot.y_axis.font = "modern 16" # Set colors #plot.title_color = "white" #for axis in plot.x_axis, plot.y_axis: # axis.set(title_color="white", tick_label_color="white") # Right now, some of the tools are a little invasive, and we need the # actual ColomappedScatterPlot object to give to them cmap_renderer = plot.plots["my_plot"][0] # Attach some tools to the plot plot.tools.append(PanTool(plot, constrain_key="shift")) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) selection = ColormappedSelectionOverlay(cmap_renderer, fade_alpha=0.35, selection_type="mask") cmap_renderer.overlays.append(selection) plot.tools.append(MoveTool(plot, drag_button="right")) return plot
def __init__(self, options, **kwtraits): super(FiberView, self).__init__(**kwtraits) self.model = FiberModel(options) # debugging self.debug = options.debug self.model.debug = options.debug # timing parameters self.max_packets = options.max_packets self.hertz = options.hertz # extend options to model self.model.max_packets = options.max_packets self.model.preallocate_arrays() self.model.num_analog_channels = options.num_analog_channels # generate traits plot self.plot_data = ArrayPlotData(x=self.model._tdata, y=self.model._ydata) self.plot = Plot(self.plot_data) renderer = self.plot.plot(("x", "y"), type="line", name='old', color="green")[0] # self.plot.delplot('old') # recording flags self.model.recording = False self.model.trialEnded = True print 'Viewer initialized.' # should we wait for a ttl input to start? if options.ttl_start: self.model.ttl_start = True self.ttl_received = False # initialize FIO0 for TTL input self.FIO0_DIR_REGISTER = 6100 self.FIO0_STATE_REGISTER = 6000 self.model.labjack.writeRegister(self.FIO0_DIR_REGISTER, 0) # Set FIO0 low # initialize output array self.out_arr = None # keep track of number of runs self.run_number = 0 self.timer = Timer(self.model.dt, self.time_update) # update every 1 ms
def _create_plot_component(): # Create some x-y data series to plot x = linspace(-2.0, 10.0, 100) pd = ArrayPlotData(index = x) for i in range(5): pd.set_data("y" + str(i), jn(i,x)) # Create some line plots of some of the data plot = Plot(pd, title="Line Plot", padding=50, border_visible=True) plot.legend.visible = True plot.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="auto") plot.plot(("index", "y3"), name="j_3", color="auto") plot.x_grid.line_color = "black" plot.y_grid.line_color = "black" xmin, xmax = 1.0, 6.0 ymin, ymax = 0.2, 0.80001 plot.x_grid.set(data_min = xmin, data_max = xmax, transverse_bounds = (ymin, ymax), transverse_mapper = plot.y_mapper) plot.y_grid.set(data_min = ymin, data_max = ymax, transverse_bounds = (xmin, xmax), transverse_mapper = plot.x_mapper) # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) # A second plot whose vertical grid lines are clipped to the jn(3) function def my_bounds_func(ticks): """ Returns y_low and y_high for each grid tick in the array **ticks** """ tmp = array([zeros(len(ticks)),jn(3, ticks)]).T return tmp func_plot = Plot(pd, padding=50, border_visible=True) func_plot.plot(("index", "y3"), color="red") func_plot.x_grid.set(transverse_bounds = my_bounds_func, transverse_mapper = func_plot.y_mapper, line_color="black") func_plot.tools.append(PanTool(func_plot)) container = HPlotContainer() container.add(plot) container.add(func_plot) return container
def _create_plot_component(): # Create some data npts = 100 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="slategray", marker_size=6, bgcolor="white") # Tweak some of the plot properties plot.title = "Scatter Plot With 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 my_plot.tools.append(ScatterInspector(my_plot, selection_mode="toggle", persistent_hover=False)) my_plot.overlays.append( ScatterInspectorOverlay(my_plot, hover_color = "transparent", hover_marker_size = 10, hover_outline_color = "purple", hover_line_width = 2, selection_marker_size = 8, selection_color = "lawngreen") ) my_plot.tools.append(PanTool(my_plot)) my_plot.overlays.append(ZoomTool(my_plot, drag_button="right")) return plot
def _plot_default(self): pd = ArrayPlotData() plot = Plot(pd, padding = 0) self.fid._data = self.panner.buffer pd.set_data("imagedata", self.fid) img_plot = plot.img_plot("imagedata", colormap=algae, interpolation='nearest', xbounds=(0.0, 1.0), ybounds=(0.0, 1.0))[0] self.fid.data_range = plot.range2d self.helper.index = img_plot.index self.img_plot = img_plot return plot
def main(): # Create some x-y data series to plot x = linspace(-2.0, 10.0, 100) pd = ArrayPlotData(index = x) for i in range(5): pd.set_data("y" + str(i), jn(i,x)) # Create some line plots of some of the data plot = Plot(pd, bgcolor="none", padding=30, border_visible=True, overlay_border=True, use_backbuffer=False) plot.legend.visible = True plot.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="auto") plot.plot(("index", "y3"), name="j_3", color="auto") plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) # Create the mlab test mesh and get references to various parts of the # VTK pipeline f = mlab.figure(size=(600,500)) m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor plot.resizable = "" plot.bounds = [200,200] plot.padding = 25 plot.outer_position = [30,30] plot.tools.append(MoveTool(component=plot,drag_button="right")) container = OverlayPlotContainer(bgcolor = "transparent", fit_window = True) container.add(plot) # Create the Enable Window window = EnableVTKWindow(rwi, renderer, component=container, #istyle_class = tvtk.InteractorStyleSwitch, #istyle_class = tvtk.InteractorStyle, istyle_class = tvtk.InteractorStyleTrackballCamera, bgcolor = "transparent", event_passthrough = True, ) mlab.show() return window, render_window
def __init__(self, link): super(SolutionView, self).__init__() self.link = link self.link.add_callback(MSG_SOLUTION, self.solution_callback) self.link.add_callback(MSG_SOLUTION_DOPS, self.dops_callback) self.link.add_callback(MSG_SOLUTION_PRS, self.prs_callback) self.link.add_callback(MSG_SOLUTION_PRED_PRS, self.pred_prs_callback) self.plot_data = ArrayPlotData(n=[0.0], e=[0.0], h=[0.0], t=[0.0], ref_n=[0.0], ref_e=[0.0]) self.plot = Plot(self.plot_data) #, auto_colors=colours_list) self.plot.plot(('n', 'e'), type='scatter', color='blue', marker='plus') self.plot.plot(('ref_n', 'ref_e'), type='scatter', color='red', marker='cross', marker_size=10, line_width=1.5 ) #self.plot.plot(('h', 'e'), type='line', color='red') self.pr_plot_data = ArrayPlotData(t=[0.0]) self.pr_plot = Plot(self.pr_plot_data, auto_colors=colours_list) self.pr_plot.value_range.tight_bounds = False #self.pr_plot.value_range.low_setting = 0.0 for n in range(TRACK_N_CHANNELS): self.pr_plot_data.set_data('prs'+str(n), [0.0]) self.pr_plot.plot(('t', 'prs'+str(n)), type='line', color='auto') #self.pr_plot_data.set_data('pred_prs'+str(n), [0.0]) #self.pr_plot.plot(('t', 'pred_prs'+str(n)), type='line', color='auto') self.python_console_cmds = { 'solution': self }
def __init__(self,*args, **kw): super(FieldDataController, self).__init__(*args, **kw) #self.plotdata = ArrayPlotData(x = self.model.index, y = self.model.data) self.model.intensity_map = zeros((100,100)) # Create a plot data obect and give it this data self.plot_data = ArrayPlotData() self.plot_data.set_data("imagedata", self.model.intensity_map) # Create a contour polygon plot of the data plot = Plot(self.plot_data, default_origin="top left") plot.contour_plot("imagedata", type="poly", poly_cmap=jet, name='Intensity map') # Create a contour line plot for the data, too plot.contour_plot("imagedata", type="line") # Tweak some of the plot properties plot.title = "Intensity Map" plot.padding = 50 plot.bg_color = "black" plot.fill_padding = True # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) dragzoom = DragZoom(plot, drag_button="right") plot.tools.append(dragzoom) plot.tools.append(CustomTool(plot)) #plot.x_axis.title = 'Index' #plot.y_axis.title = r'Power [$\mu$W]' #self.renderer = plot.plot(("x", "y"), type="line", color="black") self.plot = plot
def _create_window(self, title, xtitle, x, ytitle, y, type="line", color="blue"): self.plotdata = ArrayPlotData(x=x, y=y) plot = ToolbarPlot(self.plotdata) plot.plot(('x', 'y'), type=type, color=color) plot.title = title plot.x_axis.title = xtitle plot.y_axis.title = ytitle self.plot = plot self._hid = 0 self._colors = ['blue', 'red', 'black', 'green', 'magenta', 'yellow'] # Add some tools self.plot.tools.append(PanTool(self.plot, constrain_key="shift")) self.plot.overlays.append(ZoomTool(component=self.plot, tool_mode="box", always_on=False)) return Window(self, -1, component=plot)
def __init__(self, **traits): super(ContainerExample, self).__init__(**traits) x = np.linspace(-14, 14, 100) y = np.sin(x) * x**3 / 1000 data = ArrayPlotData(x=x, y=y) p1 = Plot(data, padding=30) p1.plot(("x", "y"), type="scatter", color="blue") p1.plot(("x", "y"), type="line", color="blue") p2 = Plot(data, padding=30) p2.plot(("x", "y"), type="line", color="blue") p2.set(bounds=[200, 100], position=[70, 150], bgcolor=(0.9, 0.9, 0.9), unified_draw=True, resizable="") p3 = Plot(data, padding=30) p3.plot(("x", "y"), type="line", color="blue", line_width=2.0) p4 = Plot(data, padding=30) p4.plot(("x", "y"), type="scatter", color="red", marker="circle") c1 = OverlayPlotContainer(p1, p2) c1.fixed_preferred_size = p3.get_preferred_size() c2 = HPlotContainer(c1, p3) c3 = VPlotContainer(p4, c2) self.plot = c3
def __init__(self): x, y = np.ogrid[-2*np.pi:2*np.pi:256j, -2*np.pi:2*np.pi:256j] self.img_data = np.sin(x)*y #self.img_mask = np.zeros((len(x), len(y[0]), 4), dtype=np.uint8) #self.img_mask[:, :, 3] = 255 self.img_index = np.array(list((np.broadcast(y, x)))) plotdata = ArrayPlotData(img_data=self.img_data, mask_data=self.img_data) plot1 = Plot(plotdata, padding=10) img_plot = plot1.img_plot("img_data", xbounds=(np.min(x), np.max(x)), ybounds=(np.min(y), np.max(y)))[0] self.lasso = LassoSelection(img_plot) img_plot.tools.append(self.lasso) self.ll = LassoOverlay(img_plot, lasso_selection=self.lasso) img_plot.overlays.append(self.ll) self.lasso.on_trait_change(self._selection_changed, 'selection_completed') plot2 = Plot(plotdata, padding=10) plot2.img_plot("mask_data") self.plot = HPlotContainer(plot1, plot2) self.plot1 = plot1 self.plot2 = plot2 self.plotdata = plotdata
def __init__(self, **traits): super(HistDemo, self).__init__(**traits) img = cv.imread("lena.jpg") gray_img = cv.Mat() cv.cvtColor(img, gray_img, cv.CV_BGR2GRAY) self.img = gray_img self.img2 = self.img.clone() result = cv.MatND() r = cv.vector_float32([0, 256]) ranges = cv.vector_vector_float32([r, r]) cv.calcHist(cv.vector_Mat([self.img]), channels=cv.vector_int([0, 1]), mask=cv.Mat(), hist=result, histSize=cv.vector_int([256]), ranges=ranges) data = ArrayPlotData(x=np.arange(0, len(result[:])), y=result[:]) self.plot = Plot(data, padding=10) line = self.plot.plot(("x", "y"))[0] self.select_tool = RangeSelection(line, left_button_selects=True) line.tools.append(self.select_tool) self.select_tool.on_trait_change(self._selection_changed, "selection") line.overlays.append(RangeSelectionOverlay(component=line)) cv.imshow("Hist Demo", self.img) self.timer = Timer(50, self.on_timer)
def __init__(self, **traits): super(PointSelectionDemo, self).__init__(**traits) x = np.random.rand(100) y = np.random.rand(100) data = ArrayPlotData(x=x, y=y) plot = Plot(data, padding=25) self.scatter = scatter = plot.plot(("x", "y"), type="scatter", marker_size=4)[0] self.select_tools = {} for i, c in enumerate(Colors.keys()): hover_name = "hover_%s" % c selection_name = "selections_%s" % c self.select_tools[c] = ScatterInspector(scatter, hover_metadata_name=hover_name, selection_metadata_name=selection_name) scatter.overlays.append(ScatterInspectorOverlay(scatter, hover_metadata_name = hover_name, selection_metadata_name=selection_name, hover_color = "transparent", hover_outline_color = c, hover_marker_size = 6, hover_line_width = 1, selection_color = Colors[c], )) scatter.active_tool = self.select_tools[self.color] scatter.index.on_trait_change(self.selection_changed, 'metadata_changed') self.plot = plot self.data = data
def __init__(self): self.data = ArrayPlotData() self.set_empty_data() self.plot = Plot(self.data, padding=10) scatter = self.plot.plot(("x","y", "c"), type="cmap_scatter", marker_size=1, color_mapper=make_color_map(), line_width=0)[0] self.plot.x_grid.visible = False self.plot.y_grid.visible = False self.plot.x_axis.visible = False self.plot.y_axis.visible = False self.tool = TrianglesTool(self.plot) self.plot.overlays.append(self.tool) try: with file("ifs_chaco.data","rb") as f: tmp = pickle.load(f) self.ifs_names = [x[0] for x in tmp] self.ifs_points = [np.array(x[1]) for x in tmp] if len(self.ifs_names) > 0: self.current_name = self.ifs_names[-1] except: pass self.tool.on_trait_change(self.triangle_changed, 'changed') self.timer = Timer(10, self.ifs_calculate)
def _plot_data_default(self): return ArrayPlotData(rx = (0.0, 1.0), ry = (0.0, 0.0), gx = (0.0, 1.0), gy = (0.0, 0.0), bx = (0.0, 1.0), by = (0.0, 0.0), ax = (0.0, 1.0), ay = (0.0, 0.0), lx = (0.0, 1.0), ly = (0.0, 0.0), ux = (0.0, 1.0), uy = (1.0, 1.0))
def _plot_default(self): pd = ArrayPlotData() plot = Plot(pd, padding=0) self.fid._data = self.panner.buffer pd.set_data("imagedata", self.fid) img_plot = plot.img_plot("imagedata", colormap=algae, interpolation='nearest', xbounds=(0.0, 1.0), ybounds=(0.0, 1.0))[0] self.fid.data_range = plot.range2d self.helper.index = img_plot.index self.img_plot = img_plot return plot
def __init__(self, **traits): super(LassoDemoPlot, self).__init__(**traits) x = np.random.random(N) y = np.random.random(N) x2 = np.array([]) y2 = np.array([]) data = ArrayPlotData(x=x, y=y, x2=x2, y2=y2) plot1 = Plot(data, padding=10) scatter_plot1 = plot1.plot(("x", "y"), type="scatter", marker="circle", color="blue")[0] self.lasso = LassoSelection(scatter_plot1, incremental_select=True, selection_datasource=scatter_plot1.index) self.lasso.on_trait_change(self._selection_changed, 'selection_changed') scatter_plot1.tools.append(self.lasso) scatter_plot1.overlays.append( LassoOverlay(scatter_plot1, lasso_selection=self.lasso)) plot2 = Plot(data, padding=10) plot2.index_range = plot1.index_range plot2.value_range = plot1.value_range plot2.plot(("x2", "y2"), type="scatter", marker="circle", color="red") self.plot = HPlotContainer(plot1, plot2) self.plot2 = plot2 self.data = data
def __init__(self, signal_instance): super(TemplatePicker, self).__init__() try: import cv except: print "OpenCV unavailable. Can't do cross correlation without it. Aborting." return None self.OK_custom=OK_custom_handler() self.sig=signal_instance if not hasattr(self.sig.mapped_parameters,"original_files"): self.sig.data=np.atleast_3d(self.sig.data) self.titles=[self.sig.mapped_parameters.name] else: self.numfiles=len(self.sig.mapped_parameters.original_files.keys()) self.titles=self.sig.mapped_parameters.original_files.keys() tmp_plot_data=ArrayPlotData(imagedata=self.sig.data[self.top:self.top+self.tmp_size,self.left:self.left+self.tmp_size,self.img_idx]) tmp_plot=Plot(tmp_plot_data,default_origin="top left") tmp_plot.img_plot("imagedata", colormap=jet) tmp_plot.aspect_ratio=1.0 self.tmp_plot=tmp_plot self.tmp_plotdata=tmp_plot_data self.img_plotdata=ArrayPlotData(imagedata=self.sig.data[:,:,self.img_idx]) self.img_container=self._image_plot_container() self.crop_sig=None
def _create_plot_component(self): self.data = ArrayPlotData() self.data["frequency"] = np.linspace(0., SAMPLING_RATE/2.0, num=NUM_SAMPLES/2) for i in range(NUM_LINES): self.data['amplitude%d' % i] = np.zeros(NUM_SAMPLES/2) self.data["time"] = np.linspace(0., float(NUM_SAMPLES)/SAMPLING_RATE, num=NUM_SAMPLES) self.data['time_amplitude'] = np.zeros(NUM_SAMPLES) self.data['imagedata'] = np.zeros(( NUM_SAMPLES/2, SPECTROGRAM_LENGTH)) spectrum_plot = Plot(self.data) for i in range(NUM_LINES): if i==NUM_LINES-1: linewidth = 2 color = (1,0,0) else: linewidth = 1 c = (NUM_LINES-i-1)/float(NUM_LINES) color = (1, 0.5+c/2, c) spectrum_plot.plot(("frequency", "amplitude%d" % i), name="Spectrum%d" % i, color=color, line_width=linewidth) spectrum_plot.padding_bottom = 20 spectrum_plot.padding_top = 20 spec_range = list(spectrum_plot.plots.values())[0][0].value_mapper.range spec_range.low = -90 spec_range.high = 0.0 spectrum_plot.index_axis.title = 'Frequency(Hz)' spectrum_plot.value_axis.title = 'Amplitude(dB)' time_plot = Plot(self.data) time_plot.plot(("time", "time_amplitude"), name="Time", color="blue") time_plot.padding_top = 20 time_plot.padding_bottom = 20 time_plot.index_axis.title = 'Time (seconds)' time_plot.value_axis.title = 'Amplitude' time_range = list(time_plot.plots.values())[0][0].value_mapper.range time_range.low = -1.5 time_range.high = 1.5 spectrogram_plot = Plot(self.data) spectrogram_time = (0.0, SPECTROGRAM_LENGTH*NUM_SAMPLES/float(SAMPLING_RATE)) spectrogram_freq = (0.0, SAMPLING_RATE/2.0) spectrogram_plot.img_plot('imagedata', name='Spectrogram', xbounds=spectrogram_time, ybounds=spectrogram_freq, colormap=cm.reverse(cm.Blues), ) range_obj = spectrogram_plot.plots['Spectrogram'][0].value_mapper.range range_obj.high = -20 range_obj.low = -60 spectrogram_plot.padding_bottom = 20 spectrogram_plot.padding_top = 20 container = VPlotContainer() container.add(time_plot) container.add(spectrum_plot) container.add(spectrogram_plot) return container
def _init_plots(self): # fitness self.fitness_plot_data = ArrayPlotData(generation=N.zeros(1), best=N.zeros(1), average=N.zeros(1)) self.fitness_plot = Plot(self.fitness_plot_data) self.fitness_plot.legend.visible = True self.fitness_plot.set(padding_top = 5, padding_right = 5, padding_bottom = 20, padding_left = 40) self.fitness_plot.plot(('generation', 'best'), color='green', line_width=2, name='best') self.fitness_plot.plot(('generation', 'average'), color='black', name='avg')
def __init__(self, **traits): super(AnimationPlot, self).__init__(**traits) data = ArrayPlotData(x=[0], y=[0]) plot = Plot(data) plot.plot(("x", "y"), type="line", color="blue") plot.title = "sin(x)" self.plot = plot self.data = data
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 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_plot_component(): # Use n_gon to compute center locations for our polygons points = n_gon(center=(0, 0), r=4, nsides=8) # Choose some colors for our polygons colors = { 3: 0xAABBCC, 4: "orange", 5: "yellow", 6: "lightgreen", 7: "green", 8: "blue", 9: "lavender", 10: "purple", } # Create a PlotData object to store the polygon data pd = ArrayPlotData() # Create a Polygon Plot to draw the regular polygons polyplot = Plot(pd) # Store path data for each polygon, and plot nsides = 3 for p in points: npoints = n_gon(center=p, r=2, nsides=nsides) nxarray, nyarray = transpose(npoints) pd.set_data("x" + str(nsides), nxarray) pd.set_data("y" + str(nsides), nyarray) plot = polyplot.plot( ("x" + str(nsides), "y" + str(nsides)), type="polygon", face_color=colors[nsides], hittest_type="poly" )[0] plot.tools.append(DataspaceMoveTool(plot, drag_button="right")) nsides = nsides + 1 # Tweak some of the plot properties polyplot.padding = 50 polyplot.title = "Polygon Plot" # Attach some tools to the plot polyplot.tools.append(PanTool(polyplot)) zoom = ZoomTool(polyplot, tool_mode="box", always_on=False) polyplot.overlays.append(zoom) return polyplot
def load_data(self,X,Y) : self.X = X self.Y = Y plotdata = ArrayPlotData(x = X, y = Y) plot = Plot(plotdata) self.renderer_line = plot.plot(('x','y'),type = 'line', color = "blue")[0] self.renderer_scat = plot.plot(('x','y'),type = 'scatter', color = "blue")[0] self.plot = plot
class TracePlot(BasePlot): def __init__(self, parent, **kw): self._type = kw.pop('type', 'scatter') self.nr_of_points = kw.pop('nr_of_points', 0) # TODO: more options BasePlot.__init__(self, parent, **kw) def add_point(self, x, y): self._x.append(x) self._y.append(y) self._set_data() def set_nr_of_points(self, n): self.nr_of_points = n self._set_data() def reset(self): self._x = [] self._y = [] self._set_data() def _set_data(self): if self.nr_of_points > 0: while len(self._x) > self.nr_of_points: self._x = self._x[1:] self._y = self._y[1:] self.data.set_data('x', self._x) self.data.set_data('y', self._y) def _create_window(self, **kw): self.data = ArrayPlotData() self.plot = Plot(self.data) self._x = [] self._y = [] self.data.set_data('x', self._x) self.data.set_data('y', self._y) self.plot.plot(('x', 'y'), type = self._type, name = 'trace') return Window(self, -1, component=self.plot)
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 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 __init__(self, **traits): super(MandelbrotDemo, self).__init__(**traits) self.data = ArrayPlotData(image=np.zeros((1, 1))) self.plot = Plot(self.data, padding=0) imgplot = self.plot.img_plot("image", colormap=reverse(Blues), interpolation="bilinear")[0] imgplot.tools.append( MandelbrotController(imgplot, application=self) ) self.imgplot = imgplot self.plot.x_axis.visible = False self.plot.y_axis.visible = False
def __init__(self): super(LinePlot, self).__init__() x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x=x, y=y) plot = Plot(plotdata) plot.plot(("x", "y"), type="line", color="blue") plot.title = "sin(x) * x^3" self.plot = plot
def __init__(self): super(ScatterPlotTraits, self).__init__() x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x=x, y=y) plot = Plot(plotdata) self.renderer = plot.plot(("x", "y"), type="scatter", color="blue")[0] self.plot = plot
def init_data(self): file_name = '/home/dpothina/work/apps/pysonde/tests/ysi_test_files/BAYT_20070323_CDT_YS1772AA_000.dat' sonde = Sonde(file_name) sal_ds = np.array([1, 2, 3, 4, 5, 6, 7, 8]) # sonde.data['seawater_salinity'] time_ds = sal_ds**2 # [time.mktime(date.utctimetuple()) for date in sonde.dates] #time_ds = ArrayDataSource(dt) #sal_ds = ArrayDataSource(salinity, sort_order="none") self.plot_data = ArrayPlotData(sal_ds=sal_ds, time_ds=time_ds)
def _init_plots(self): # fitness self.fitness_plot_data = ArrayPlotData(generation=N.zeros(1), best=N.zeros(1), average=N.zeros(1)) self.fitness_plot = Plot(self.fitness_plot_data) self.fitness_plot.legend.visible = True self.fitness_plot.set(padding_top=5, padding_right=5, padding_bottom=20, padding_left=40) self.fitness_plot.plot(('generation', 'best'), color='green', line_width=2, name='best') self.fitness_plot.plot(('generation', 'average'), color='black', name='avg')
def __init__(self, **traits): super(LinePlot, self).__init__(**traits) x = np.linspace(-14, 14, 100) y = np.sin(x) * x**3 data = ArrayPlotData(x=x, y=y) plot = Plot(data) plot.plot(("x", "y"), type="line", color="blue") plot.title = "sin(x) * x^3" self.plot = plot self.data = data
def __init__(self): x = numpy.linspace(-14, 14, 100) y = numpy.sin(x) * x**3 plotdata = ArrayPlotData(x=x, y=y) plot = Plot(plotdata) plot.plot(("x", "y"), type="line", color="blue") plot.title = "sin(x) * x^3" self.plot=plot
def __init__(self): super(ImagePlot, self).__init__() x = np.linspace(0, 10, 50) y = np.linspace(0, 5, 50) xgrid, ygrid = np.meshgrid(x, y) z = np.exp(-(xgrid * xgrid + ygrid * ygrid) / 100) plotdata = ArrayPlotData(imagedata=z) plot = Plot(plotdata) plot.img_plot("imagedata", xbounds=x, ybounds=y, colormap=jet) self.plot = plot
def __init__(self, **traits): super(ScatterPlotTraits, self).__init__(**traits) x = np.linspace(-14, 14, 100) y = np.sin(x) * x**3 data = ArrayPlotData(x=x, y=y) plot = Plot(data) self.line = plot.plot(("x", "y"), type="scatter", color="blue")[0] self.plot = plot self.data = data
def __init__(self, dims=(128, 10)): super(ImagePlot, self).__init__() z = numpy.zeros(dims) self.plotdata = ArrayPlotData(imagedata=z) plot = Plot(self.plotdata) plot.img_plot("imagedata", xbounds=(0, dims[1]), ybounds=(0, dims[0]), colormap=self._cmap) self.plot = plot self.flag = True
def __init__(self): super(ContainerExample, self).__init__() x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x=x, y=y) scatter = Plot(plotdata) scatter.plot(("x", "y"), type="scatter", color="blue") line = Plot(plotdata) line.plot(("x", "y"), type="line", color="blue") container = HPlotContainer(scatter, line) self.plot = container
def _create_window(self, title, xtitle, x, ytitle, y, z): ''' - Left-drag pans the plot. - Mousewheel up and down zooms the plot in and out. - Pressing "z" brings up the Zoom Box, and you can click-drag a rectangular region to zoom. If you use a sequence of zoom boxes, pressing alt-left-arrow and alt-right-arrow moves you forwards and backwards through the "zoom history". ''' self._plotname = title # Create window self.data = ArrayPlotData() self.plot = Plot(self.data) self.update_plot(x, y, z) self.plot.title = title self.plot.x_axis.title = xtitle self.plot.y_axis.title = ytitle cmap_renderer = self.plot.plots[self._plotname][0] # Create colorbar self._create_colorbar() self._colorbar.plot = cmap_renderer self._colorbar.padding_top = self.plot.padding_top self._colorbar.padding_bottom = self.plot.padding_bottom # Add some tools self.plot.tools.append(PanTool(self.plot, constrain_key="shift")) self.plot.overlays.append( ZoomTool(component=self.plot, tool_mode="box", always_on=False)) # selection = ColormappedSelectionOverlay(cmap_renderer, fade_alpha=0.35, selection_type="mask") # cmap_renderer.overlays.append(selection) # Create a container to position the plot and the colorbar side-by-side container = HPlotContainer(use_backbuffer=True) container.add(self.plot) container.add(self._colorbar) self.container = container # Return a window containing our plot container return Window(self, -1, component=container)