def _qplot_default(self): # Force an update of the array data sources so changes are plotted self.xs.set_data(self.particles.x, sort_order='ascending') self.ys.set_data(self.particles.y) #self.vector_ds = MultiArrayDataSource(self.vectors) self.vector_ds.set_data(self.vectors) # Set up the Plot xrange = DataRange1D() xrange.add(self.xs) xrange.set_bounds(0,self.xsize) yrange = DataRange1D() yrange.add(self.ys) yrange.set_bounds(0,self.ysize) qplot = QuiverPlot(index = self.xs, value = self.ys, vectors = self.vector_ds, #data_type = 'radial', # not implemented index_mapper = LinearMapper(range=xrange), value_mapper = LinearMapper(range=yrange), bgcolor = "white", line_color = "grey") qplot.aspect_ratio = float(self.xsize) / float(self.ysize) return qplot
def _create_plot_component(): # Create some data numpts = 400 x = sort(random(numpts)) y = random(numpts) xs = ArrayDataSource(x, sort_order='ascending') ys = ArrayDataSource(y) vectorlen = 15 vectors = array((random(numpts) * vectorlen, random(numpts) * vectorlen)).T vector_ds = MultiArrayDataSource(vectors) xrange = DataRange1D() xrange.add(xs) yrange = DataRange1D() yrange.add(ys) quiverplot = QuiverPlot(index=xs, value=ys, vectors=vector_ds, index_mapper=LinearMapper(range=xrange), value_mapper=LinearMapper(range=yrange), bgcolor="white") add_default_axes(quiverplot) add_default_grids(quiverplot) # Attach some tools to the plot quiverplot.tools.append(PanTool(quiverplot, constrain_key="shift")) zoom = ZoomTool(quiverplot) quiverplot.overlays.append(zoom) container = OverlayPlotContainer(quiverplot, padding=50) return container
def _plot_default(self): # Array data sources, each single element arrays x_ds = ArrayDataSource([self.robot.x]) y_ds = ArrayDataSource([self.robot.y]) vector_ds = MultiArrayDataSource() vector_ds.set_data(self.vector) # Set up the ranges for the plot explicitly (no autosizing) x_r = DataRange1D(x_ds) x_r.set_bounds(0,self.xsize) y_r = DataRange1D(y_ds) y_r.set_bounds(0,self.ysize) plot = QuiverPlot(index = x_ds, value = y_ds, vectors = vector_ds, index_mapper = LinearMapper(range=x_r), value_mapper = LinearMapper(range=y_r), bgcolor = "white", line_color = self.color, line_width = 2.0) plot.aspect_ratio = float(self.xsize) / float(self.ysize) return plot