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 _traj_plot_default(self): """Trajectory plot based on TrajectoryView.t_plot in chaco_threading_demo""" zero = numpy.array([0], 'd') data = ArrayPlotData(x=zero, y=zero) h, w = self.traj.Map.H, self.traj.Map.W data.set_data('x0', zero + self.traj.Map.x0[0]) data.set_data('y0', zero + self.traj.Map.x0[1]) p = Plot(data) p.plot(('x', 'y'), name='trail', color='red') p.plot(('x0', 'y0'), name='head', type='scatter', marker='circle', color='red') p.y_axis.visible = p.x_axis.visible = False p.y_grid.visible = p.x_grid.visible = False p.border_visible = True p.border_width = 2 p.title = 'Rat Trajectory' p.index_range.set_bounds(0, w) p.value_range.set_bounds(0, h) p.overlays.append(PlotLabel('X (%d cm)'%w, component=p, overlay_position='bottom')) p.overlays.append(PlotLabel('Y (%d cm)'%h, component=p, overlay_position='left', angle=90)) return p
def _plot_default(self): outcomes, results, time = self._prepare_data() self.outcomes = outcomes self.time = time self.low = int(np.min(time)) self.high = int(np.max(time)) self.data = {} for outcome in outcomes: self.data[outcome] = results[outcome] # Create some data pd = ArrayPlotData() for entry in outcomes: if self.startValue == 'low': pd.set_data(entry, self.data[entry][:,0]) elif self.startValue == 'high': pd.set_data(entry, self.data[entry][:,-1]) self.plotdata = pd # outcomes = outcomes[0:3] container = GridContainer(shape=(len(outcomes),len(outcomes))) combis = [(field1, field2) for field1 in outcomes for field2 in outcomes] selectorTools = [] for entry1, entry2 in combis: # Create the plot if entry1 == entry2: plot = Plot(pd) else: plot = Plot(pd) #set limits for x and y to global limits plot.range2d._xrange._high_setting = np.max(self.data[entry1]) plot.range2d._xrange._high_value = np.max(self.data[entry1]) plot.range2d._xrange._low_setting = np.min(self.data[entry1]) plot.range2d._xrange._low_value = np.min(self.data[entry1]) plot.range2d._yrange._high_setting =np.max(self.data[entry2]) plot.range2d._yrange._high_value = np.max(self.data[entry2]) plot.range2d._yrange._low_setting = np.min(self.data[entry2]) plot.range2d._yrange._low_value = np.min(self.data[entry2]) #make the scatter plot plot.plot((entry1, entry2), type="scatter", marker="circle", color="blue", marker_size=3, bgcolor="white")[0] tool = ScatterSelectorTool(component=plot) tool._index = entry1 plot.tools.append(tool) selectorTools.append(tool) plot.height = 500 plot.width = 500 plot.border_width = 1 plot.aspect_ratio = 1. container.add(plot) for tool in selectorTools: tool._other_selectors = list(set(selectorTools) - set([tool])) tool._demo = self return container