def apply_roi(self, roi, override_mode=None): # Force redraw to get rid of ROI. We do this because applying the # subset state below might end up not having an effect on the viewer, # for example there may not be any layers, or the active subset may not # be one of the layers. So we just explicitly redraw here to make sure # a redraw will happen after this method is called. self.redraw() if len(self.layers) == 0: return x_date = 'datetime' in self.state.x_kinds if x_date: roi = roi.transformed(xfunc=mpl_to_datetime64 if x_date else None) bins = self.state.bins x = roi.to_polygon()[0] lo, hi = min(x), max(x) if lo >= bins.min(): lo = bins[bins <= lo].max() if hi <= bins.max(): hi = bins[bins >= hi].min() roi_new = RangeROI(min=lo, max=hi, orientation='x') subset_state = roi_to_subset_state( roi_new, x_att=self.state.x_att, x_categories=self.state.x_categories) self.apply_subset_state(subset_state, override_mode=override_mode)
def apply_roi(self, roi, override_mode=None): # Force redraw to get rid of ROI. We do this because applying the # subset state below might end up not having an effect on the viewer, # for example there may not be any layers, or the active subset may not # be one of the layers. So we just explicitly redraw here to make sure # a redraw will happen after this method is called. self.redraw() if len(self.layers) == 0: return x_date = 'datetime' in self.state.x_kinds if x_date: roi = roi.transformed(xfunc=mpl_to_datetime64 if x_date else None) bins = self.state.bins x = roi.to_polygon()[0] lo, hi = min(x), max(x) if lo >= bins.min(): lo = bins[bins <= lo].max() if hi <= bins.max(): hi = bins[bins >= hi].min() roi_new = RangeROI(min=lo, max=hi, orientation='x') subset_state = roi_to_subset_state(roi_new, x_att=self.state.x_att, x_categories=self.state.x_categories) self.apply_subset_state(subset_state, override_mode=override_mode)
def apply_roi(self, roi, override_mode=None): # Force redraw to get rid of ROI. We do this because applying the # subset state below might end up not having an effect on the viewer, # for example there may not be any layers, or the active subset may not # be one of the layers. So we just explicitly redraw here to make sure # a redraw will happen after this method is called. self.redraw() if len(self.layers) == 0: return x_date = 'datetime' in self.state.x_kinds y_date = 'datetime' in self.state.y_kinds if x_date or y_date: roi = roi.transformed(xfunc=mpl_to_datetime64 if x_date else None, yfunc=mpl_to_datetime64 if y_date else None) use_transform = self.state.plot_mode != 'rectilinear' subset_state = roi_to_subset_state( roi, x_att=self.state.x_att, x_categories=self.state.x_categories, y_att=self.state.y_att, y_categories=self.state.y_categories, use_pretransform=use_transform) if use_transform: subset_state.pretransform = ProjectionMplTransform( self.state.plot_mode, self.axes.get_xlim(), self.axes.get_ylim(), self.axes.get_xscale(), self.axes.get_yscale()) self.apply_subset_state(subset_state, override_mode=override_mode)
def apply_roi(self, roi, use_current=False): if len(self.layers) == 0: # Force redraw to get rid of ROI return self.redraw() x_date = any(comp.datetime for comp in self.state._get_x_components()) if x_date: roi = roi.transformed(xfunc=mpl_to_datetime64 if x_date else None) bins = self.state.bins x = roi.to_polygon()[0] lo, hi = min(x), max(x) if lo >= bins.min(): lo = bins[bins <= lo].max() if hi <= bins.max(): hi = bins[bins >= hi].min() roi_new = RangeROI(min=lo, max=hi, orientation='x') x_comp = self.state.x_att.parent.get_component(self.state.x_att) subset_state = roi_to_subset_state(roi_new, x_att=self.state.x_att, x_comp=x_comp) self.apply_subset_state(subset_state, use_current=use_current)
def _roi_to_subset_state(self, roi): x = roi.to_polygon()[0] lo, hi = min(x), max(x) roi_new = RangeROI(min=lo, max=hi, orientation='x') return roi_to_subset_state(roi_new, x_att=self.state.x_att)
def _roi_to_subset_state(self, roi): # TODO: copy paste from glue/viewers/image/qt/data_viewer.py#L66 # next lines don't work.. comp has no datetime? # x_date = any(comp.datetime for comp in self.state._get_x_components()) # y_date = any(comp.datetime for comp in self.state._get_y_components()) # if x_date or y_date: # roi = roi.transformed(xfunc=mpl_to_datetime64 if x_date else None, # yfunc=mpl_to_datetime64 if y_date else None) if self.is2d: return roi_to_subset_state(roi, x_att=self.state.x_att, y_att=self.state.y_att)
def apply_roi(self, roi, override_mode=None): # Force redraw to get rid of ROI. We do this because applying the # subset state below might end up not having an effect on the viewer, # for example there may not be any layers, or the active subset may not # be one of the layers. So we just explicitly redraw here to make sure # a redraw will happen after this method is called. self.redraw() if len(self.layers) == 0: return subset_state = roi_to_subset_state(roi, x_att=self.state.x_att) self.apply_subset_state(subset_state, override_mode=override_mode)
def apply_roi(self, roi, use_current=False): if len(self.layers) == 0: # Force redraw to get rid of ROI return self.redraw() if self.state.x_att is None or self.state.y_att is None or self.state.reference_data is None: return x_comp = self.state.x_att.parent.get_component(self.state.x_att) y_comp = self.state.y_att.parent.get_component(self.state.y_att) subset_state = roi_to_subset_state(roi, x_att=self.state.x_att, x_comp=x_comp, y_att=self.state.y_att, y_comp=y_comp) self.apply_subset_state(subset_state)
def _roi_to_subset_state(self, roi): # TODO: copy paste from glue/viewers/histogram/qt/data_viewer.py # TODO Does subset get applied to all data or just visible data? bins = self.state.bins x = roi.to_polygon()[0] lo, hi = min(x), max(x) if lo >= bins.min(): lo = bins[bins <= lo].max() if hi <= bins.max(): hi = bins[bins >= hi].min() roi_new = RangeROI(min=lo, max=hi, orientation='x') return roi_to_subset_state(roi_new, x_att=self.state.x_att)
def apply_roi(self, roi, override_mode=None): # Force redraw to get rid of ROI. We do this because applying the # subset state below might end up not having an effect on the viewer, # for example there may not be any layers, or the active subset may not # be one of the layers. So we just explicitly redraw here to make sure # a redraw will happen after this method is called. self.redraw() if len(self.layers) == 0: return x_date = 'datetime' in self.state.x_kinds y_date = 'datetime' in self.state.y_kinds if x_date or y_date: roi = roi.transformed(xfunc=mpl_to_datetime64 if x_date else None, yfunc=mpl_to_datetime64 if y_date else None) use_transform = self.state.plot_mode != 'rectilinear' subset_state = roi_to_subset_state( roi, x_att=self.state.x_att, x_categories=self.state.x_categories, y_att=self.state.y_att, y_categories=self.state.y_categories, use_pretransform=use_transform) if use_transform: transform = ProjectionMplTransform(self.state.plot_mode, self.axes.get_xlim(), self.axes.get_ylim(), self.axes.get_xscale(), self.axes.get_yscale()) # If we're using degrees, we need to staple on the degrees -> radians conversion beforehand if self.using_polar() and self.state.angle_unit == 'degrees': transform = partial( MatplotlibScatterMixin._radian_pretransform, transform=transform) subset_state.pretransform = transform self.apply_subset_state(subset_state, override_mode=override_mode)
def apply_roi(self, roi, use_current=False): if len(self.layers) == 0: # Force redraw to get rid of ROI return self.redraw() x_date = any(comp.datetime for comp in self.state._get_x_components()) y_date = any(comp.datetime for comp in self.state._get_y_components()) if x_date or y_date: roi = roi.transformed(xfunc=mpl_to_datetime64 if x_date else None, yfunc=mpl_to_datetime64 if y_date else None) x_comp = self.state.x_att.parent.get_component(self.state.x_att) y_comp = self.state.y_att.parent.get_component(self.state.y_att) subset_state = roi_to_subset_state(roi, x_att=self.state.x_att, x_comp=x_comp, y_att=self.state.y_att, y_comp=y_comp) self.apply_subset_state(subset_state, use_current=use_current)
def apply_roi(self, roi, override_mode=None): # Force redraw to get rid of ROI. We do this because applying the # subset state below might end up not having an effect on the viewer, # for example there may not be any layers, or the active subset may not # be one of the layers. So we just explicitly redraw here to make sure # a redraw will happen after this method is called. self.redraw() if len(self.layers) == 0: return x_date = 'datetime' in self.state.x_kinds y_date = 'datetime' in self.state.y_kinds if x_date or y_date: roi = roi.transformed(xfunc=mpl_to_datetime64 if x_date else None, yfunc=mpl_to_datetime64 if y_date else None) subset_state = roi_to_subset_state(roi, x_att=self.state.x_att, x_categories=self.state.x_categories, y_att=self.state.y_att, y_categories=self.state.y_categories) self.apply_subset_state(subset_state, override_mode=override_mode)
def apply_roi(self, roi, use_current=False): if len(self.layers) == 0: # Force redraw to get rid of ROI return self.redraw() x_comp = self.state.x_att.parent.get_component(self.state.x_att) subset_state = roi_to_subset_state(roi, x_att=self.state.x_att, x_comp=x_comp) self.apply_subset_state(subset_state, use_current=use_current)