def _startX_changed(self): if self.imageInspectorReference is None: return # not yet initialized yet self.imageInspectorReference.ROIPolyPlot.index = chaco.ArrayDataSource( [self.startX, self.endX, self.endX, self.startX]) self.imageInspectorReference.ROIPolyPlot.value = chaco.ArrayDataSource( [self.startY, self.startY, self.endY, self.endY])
def drawRescaleRegion(self, framePlot): if self.optionsDict["rescale?"]: logger.warning("drawRescaleRegion") if True: # create line polygon plot to display fit region points = np.asarray([ [ self.optionsDict["rescaleInitialX"], self.optionsDict["rescaleInitialX"]+self.optionsDict["rescaleWidth"], self.optionsDict["rescaleInitialX"]+self.optionsDict["rescaleWidth"], self.optionsDict["rescaleInitialX"] ], [ self.optionsDict["rescaleInitialY"], self.optionsDict["rescaleInitialY"], self.optionsDict["rescaleInitialY"]+self.optionsDict["rescaleHeight"], self.optionsDict["rescaleInitialY"]+self.optionsDict["rescaleHeight"] ] ]) phi = self.optionsDict["rotationAngle"] * np.pi / 180. rotMatrix = np.asarray([ [np.cos(phi), np.sin(phi)], [-np.sin(phi), np.cos(phi)] ]) print points # get old and new dimensions for scale and center of image widthOld = self.atomsArray.shape[0] heightOld = self.atomsArray.shape[1] width = self.opticalDensityArray.shape[0] height = self.opticalDensityArray.shape[1] # rotate around center points[0] = points[0] - widthOld/2. points[1] = points[1] - heightOld/2. points = rotMatrix.dot(points) points[0] = points[0] + width/2. points[1] = points[1] + height/2. rescaleRegionFrameXs = chaco.ArrayDataSource( points[0] ) rescaleRegionFrameYs = chaco.ArrayDataSource( points[1] ) framePlot.index = rescaleRegionFrameXs framePlot.value = rescaleRegionFrameYs framePlot.visible = self.optionsDict["drawRescaleRegion?"] self.framePlot = framePlot
def _create_render(self): # Create our data sources idx = _chaco.ArrayDataSource(_np.arange(self.ds.n_vars)) vals = _chaco.ArrayDataSource(self.ds.mat.ix[self.row_id].values) # Create the index range index_range = _chaco.DataRange1D(idx, tight_bounds=False, low_setting='auto', margin=0.15) index_mapper = _chaco.LinearMapper(range=index_range) # Create the value range value_range = _chaco.DataRange1D(vals, low_setting=0, high_setting=self.ceiling) value_mapper = _chaco.LinearMapper(range=value_range) # Create the plot bars = _chaco.BarPlot(index=idx, value=vals, value_mapper=value_mapper, index_mapper=index_mapper, line_color='black', fill_color='springgreen', bar_width=0.8, antialias=False) return bars
def _render_data(self, pec): idx = _chaco.ArrayDataSource(_np.arange(self.ds.n_objs)) mvals = self.stair_ds # Create the index range index_range = _chaco.DataRange1D(idx, tight_bounds=False, low_setting='auto', margin=0.15) index_mapper = _chaco.LinearMapper(range=index_range) # Create the value range value_range = _chaco.DataRange1D(mvals, tight_bounds=True) value_mapper = _chaco.LinearMapper(range=value_range) colors = hue_span(mvals.get_value_size()) bar_names = {} for i in range(mvals.get_value_size() - 1, -1, -1): vals = _chaco.ArrayDataSource(mvals.get_data(axes=i)) bars = _chaco.BarPlot(index=idx, value=vals, value_mapper=value_mapper, index_mapper=index_mapper, line_color='black', fill_color=colors[i], bar_width=0.8, antialias=False) name = str(self.ds.var_n[i]) bar_names[name] = bars num = self.ds.mat.values[:, i] pecl = pec[:, i] self._add_data_labels(bars, num, pecl) self.add(bars) rvn = bar_names.keys() rvn.sort(reverse=True) legend = _chaco.Legend(component=self, padding=2, align="ur", labels=rvn) legend.plots = bar_names self.overlays.append(legend) return bars
def _create_renderer(self): # Create our data sources bmin = _chaco.ArrayDataSource(self.ds.mat['perc25'].values) bmax = _chaco.ArrayDataSource(self.ds.mat['perc75'].values) med = _chaco.ArrayDataSource(self.ds.mat['median'].values) minv = _chaco.ArrayDataSource(self.ds.mat['min'].values) maxv = _chaco.ArrayDataSource(self.ds.mat['max'].values) idx = _chaco.ArrayDataSource(_np.arange(self.ds.n_objs)) # Create the index range index_range = _chaco.DataRange1D(idx, tight_bounds=False) index_mapper = _chaco.LinearMapper(range=index_range) # Create the value range value_range = _chaco.DataRange1D(minv, maxv, tight_bounds=False) value_mapper = _chaco.LinearMapper(range=value_range) # Color defined in enable.colors.color_table boxes = _chaco.CandlePlot(index=idx, center_values=med, bar_min=bmin, bar_max=bmax, min_values=minv, max_values=maxv, index_mapper=index_mapper, value_mapper=value_mapper, bar_color='springgreen', bar_line_color='black', center_color='forestgreen', stem_color='black', line_width=1.0, center_width=5, stem_width=1, end_cap=False) return boxes