def set_color_bins(self): if self.attr_color is None: self.thresholds = self.bin_labels = self.colors = None elif self.attr_color.is_discrete: self.thresholds = self.bin_labels = None self.colors = self.attr_color.palette else: col = self.data.get_column_view(self.attr_color)[0].astype(float) if self.attr_color.is_time: binning = time_binnings(col, min_bins=4)[-1] else: binning = decimal_binnings(col, min_bins=4)[-1] self.thresholds = binning.thresholds[1:-1] self.bin_labels = (binning.labels[1:-1], binning.short_labels[1:-1]) palette = BinnedContinuousPalette.from_palette( self.attr_color.palette, binning.thresholds) self.colors = palette
def set_color_bins(self): if self.attr_color is None: self.thresholds = self.bin_labels = self.colors = None elif self.attr_color.is_discrete: self.thresholds = self.bin_labels = None self.colors = [QColor(*color) for color in self.attr_color.colors] else: col = self.data.get_column_view(self.attr_color)[0].astype(float) if self.attr_color.is_time: binning = time_binnings(col, min_bins=4)[-1] else: binning = decimal_binnings(col, min_bins=4)[-1] self.thresholds = binning.thresholds[1:-1] self.bin_labels = (binning.labels[1:-1], binning.short_labels[1:-1]) palette = ContinuousPaletteGenerator(*self.attr_color.colors) nbins = len(self.thresholds) + 1 self.colors = [palette[i / (nbins - 1)] for i in range(nbins)]
def set_color_bins(self): self.Warning.no_defined_colors.clear() if self.attr_color is None: self.thresholds = self.bin_labels = self.colors = None return if self.attr_color.is_discrete: self.thresholds = self.bin_labels = None self.colors = self.attr_color.palette return col = self.data.get_column_view(self.attr_color)[0].astype(float) col = col[np.isfinite(col)] if not col.size: self.Warning.no_defined_colors(self.attr_color) self.thresholds = self.bin_labels = self.colors = None return if self.attr_color.is_time: binning = time_binnings(col, min_bins=4)[-1] else: binning = decimal_binnings(col, min_bins=4)[-1] self.thresholds = binning.thresholds[1:-1] self.bin_labels = (binning.labels[1:-1], binning.short_labels[1:-1]) if not self.bin_labels[0] and binning.labels: # Nan's are already filtered out, but it doesn't hurt much # to use nanmax/nanmin if np.nanmin(col) == np.nanmax(col): # Handle a degenerate case with a single value # Use the second threshold (because value must be smaller), # but the first threshold as label (because that's the # actual value in the data. self.thresholds = binning.thresholds[1:] self.bin_labels = (binning.labels[:1], binning.short_labels[:1]) palette = BinnedContinuousPalette.from_palette(self.attr_color.palette, binning.thresholds) self.colors = palette