def _get_continuous_colors(self, c_data):
        palette = self.master.get_palette()
        bins = self.master.get_binning().thresholds
        self.palette = BinnedContinuousPalette.from_palette(palette, bins)
        rgb = self.palette.values_to_colors(c_data)
        rgba = np.hstack(
            [rgb, np.full((len(rgb), 1), self.alpha_value, dtype=np.ubyte)])

        return [QBrush(QColor(*col)) for col in rgba]
Exemple #2
0
 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
Exemple #3
0
    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