def do_plotv(session, *args, **kw): """ Creates a list of plots from the data in ``*args`` and options in ``**kw``, according to the docstring on commands.plot(). """ sort = kw.get("sort", "none") sources_list = make_data_sources(session, sort, *args) plot_type = kw.get("type", "line") if plot_type == "scatter": plots = [create_scatter_plot(sources) for sources in sources_list] elif plot_type == "line": plots = [create_line_plot(sources) for sources in sources_list] else: raise ChacoShellError("Unknown plot type '%s'." % plot_type) for plot in plots: plot.orientation = kw.get("orientation", "h") return plots
def _create_2D_plot(self): index = 0 secContainer = OverlayPlotContainer(padding = 50, fill_padding = True, bgcolor = "lightgray", use_backbuffer=True) try: pcaPoints = [] for batch in self.PCAData.batchs: if (self.active_scores_combobox == "Post Scores"): y = [batch.postscores[int(self.Y_PCA)]] x = [batch.postscores[int(self.X_PCA)]] else: x = [batch.prescores[int(self.X_PCA)]] y = [batch.prescores[int(self.Y_PCA)]] for i in range(len(x)): pcaPoints.append((x[i],y[i])) if (self.Shape == self.phenotypes[0]): a = 1 elif (self.Shape == self.phenotypes[1]): a = batch.number elif (self.Shape == self.phenotypes[2]): a = batch.type else: a = 0 if (self.Color == self.phenotypes[0]): b = 0 elif(self.Color == self.phenotypes[1]): b = batch.number elif(self.Color == self.phenotypes[2]): b = batch.type else: b = 0 tmarker = shapes[a] bcolor = self.colors[b] plot = create_scatter_plot((x,y), marker = tmarker, color=getColor(bcolor)) if batch.isSelected: plot.alpha = 1 else: plot.fill_alpha = 0.2 plot.bgcolor = "white" plot.border_visible = True if index == 0: value_mapper = plot.value_mapper index_mapper = plot.index_mapper add_default_grids(plot) add_default_axes(plot, vtitle='PCA '+self.Y_PCA, htitle='PCA '+self.X_PCA) plot.index_range.tight_bounds = False plot.index_range.refresh() plot.value_range.tight_bounds = False plot.value_range.refresh() plot.tools.append(PanTool(plot)) zoom = ZoomTool(plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) dragzoom = DragZoom(plot, drag_button="right") plot.tools.append(dragzoom) else: plot.value_mapper = value_mapper value_mapper.range.add(plot.value) plot.index_mapper = index_mapper index_mapper.range.add(plot.index) secContainer.add(plot) index = index +1 lineDraw = LineDrawer2D(plot) lineDraw.setPCAData(self, self.PCAData) plot.overlays.append(lineDraw) self.LeftPlot = secContainer except ValueError: pass
def _create_1D1_plot(self): index = 0 plot0 = Plot(self.plotdata, padding=0) plot0.padding_left = 5 plot0.padding_bottom = 5 Container = OverlayPlotContainer(padding = 50, fill_padding = True, bgcolor = "lightgray", use_backbuffer=True) y1 = range(len(self.PCAData.batchs[0].prescores)) points = [] for batch in self.PCAData.batchs: if (self.active_scores_combobox == "Post Scores"): x1 = self.PCAData.batchs[index].postscores else: x1 = self.PCAData.batchs[index].prescores if (self.Shape == self.phenotypes[0]): a = 1 elif (self.Shape == self.phenotypes[1]): a = batch.number elif (self.Shape == self.phenotypes[2]): a = batch.type else: a = 0 if (self.Color == self.phenotypes[0]): b = 0 elif(self.Color == self.phenotypes[1]): b = batch.number elif(self.Color == self.phenotypes[2]): b = batch.type else: b = 0 tmarker = shapes[a] bcolor = self.colors[b] for i in range(len(x1)): points.append((x1[i],y1[i])) plot0 = create_scatter_plot((x1,y1), marker = tmarker, color=getColor(bcolor)) if batch.isSelected: plot0.alpha = 1 else: plot0.alpha = 0.2 plot0.bgcolor = "white" plot0.border_visible = True if index == 0: value_mapper = plot0.value_mapper index_mapper = plot0.index_mapper add_default_grids(plot0) add_default_axes(plot0, vtitle='PCA Indices', htitle='PCA Scores') plot0.index_range.tight_bounds = False plot0.index_range.refresh() plot0.value_range.tight_bounds = False plot0.value_range.refresh() plot0.tools.append(PanTool(plot0)) zoom = ZoomTool(plot0, tool_mode="box", always_on=False, maintain_aspect_ratio=False) plot0.overlays.append(zoom) dragzoom = DragZoom(plot0, drag_button="right", maintain_aspect_ratio=False) plot0.tools.append(dragzoom) else: plot0.value_mapper = value_mapper value_mapper.range.add(plot0.value) plot0.index_mapper = index_mapper index_mapper.range.add(plot0.index) Container.add(plot0) index = index +1 self.RightPlot = Container
def _create_2D_plot(self): index = 0 secContainer = OverlayPlotContainer(padding=50, fill_padding=True, bgcolor="lightgray", use_backbuffer=True) try: pcaPoints = [] for batch in self.PCAData.batchs: if (self.active_scores_combobox == "Post Scores"): y = [batch.postscores[int(self.Y_PCA)]] x = [batch.postscores[int(self.X_PCA)]] else: x = [batch.prescores[int(self.X_PCA)]] y = [batch.prescores[int(self.Y_PCA)]] for i in range(len(x)): pcaPoints.append((x[i], y[i])) ''' if (self.Shape == self.phenotypes[0]): a = 1 elif (self.Shape == self.phenotypes[1]): a = batch.number elif (self.Shape == self.phenotypes[2]): a = batch.type else: a = 0 if (self.Color == self.phenotypes[0]): b = 0 elif(self.Color == self.phenotypes[1]): b = batch.number elif(self.Color == self.phenotypes[2]): b = batch.type else: b = 0 ''' a = batch.type b = batch.number tmarker = shapes[a] bcolor = self.colors[b] plot = create_scatter_plot((x, y), marker=tmarker, color=getColor(bcolor)) if batch.isSelected: plot.alpha = 1 else: plot.alpha = 0.2 plot.bgcolor = "white" plot.border_visible = True if index == 0: value_mapper = plot.value_mapper index_mapper = plot.index_mapper add_default_grids(plot) add_default_axes(plot, vtitle='PCA ' + self.Y_PCA, htitle='PCA ' + self.X_PCA) plot.index_range.tight_bounds = False plot.index_range.refresh() plot.value_range.tight_bounds = False plot.value_range.refresh() plot.tools.append(PanTool(plot)) zoom = ZoomTool(plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) dragzoom = DragZoom(plot, drag_button="right") plot.tools.append(dragzoom) else: plot.value_mapper = value_mapper value_mapper.range.add(plot.value) plot.index_mapper = index_mapper index_mapper.range.add(plot.index) if batch.isSelected: secContainer.add(plot) index = index + 1 lineDraw = LineDrawer2D(plot) lineDraw.setPCAData(self, self.PCAData) plot.overlays.append(lineDraw) self.LeftPlot = secContainer except ValueError: pass
def _create_1D1_plot(self): index = 0 plot0 = Plot(self.plotdata, padding=0) plot0.padding_left = 5 plot0.padding_bottom = 5 Container = OverlayPlotContainer(padding=50, fill_padding=True, bgcolor="lightgray", use_backbuffer=True) y1 = range(len(self.PCAData.batchs[0].prescores)) points = [] for batch in self.PCAData.batchs: if (self.active_scores_combobox == "Post Scores"): x1 = self.PCAData.batchs[index].postscores else: x1 = self.PCAData.batchs[index].prescores '''if (self.Shape == self.phenotypes[0]): a = 1 elif (self.Shape == self.phenotypes[1]): a = batch.number elif (self.Shape == self.phenotypes[2]): a = batch.type else: a = 0 if (self.Color == self.phenotypes[0]): b = 0 elif(self.Color == self.phenotypes[1]): b = batch.number elif(self.Color == self.phenotypes[2]): b = batch.type else: b = 0 ''' a = batch.type b = batch.number tmarker = shapes[a] bcolor = self.colors[b] for i in range(len(x1)): points.append((x1[i], y1[i])) plot0 = create_scatter_plot((x1, y1), marker=tmarker, color=getColor(bcolor)) if batch.isSelected: plot0.alpha = 1 plot0.alpha = 1 else: plot0.fill_alpha = 0.2 plot0.edge_alpha = 0.2 plot0.bgcolor = "white" plot0.border_visible = True if index == 0: value_mapper = plot0.value_mapper index_mapper = plot0.index_mapper add_default_grids(plot0) add_default_axes(plot0, vtitle='PCA Indices', htitle='PCA Scores') plot0.index_range.tight_bounds = False plot0.index_range.refresh() plot0.value_range.tight_bounds = False plot0.value_range.refresh() plot0.tools.append(PanTool(plot0)) zoom = ZoomTool(plot0, tool_mode="box", always_on=False, maintain_aspect_ratio=False) plot0.overlays.append(zoom) dragzoom = DragZoom(plot0, drag_button="right", maintain_aspect_ratio=False) plot0.tools.append(dragzoom) else: plot0.value_mapper = value_mapper value_mapper.range.add(plot0.value) plot0.index_mapper = index_mapper index_mapper.range.add(plot0.index) if batch.isSelected: Container.add(plot0) index = index + 1 self.RightPlot = Container