Example #1
0
 def _color_map(self) -> GradientColorMap:
     palette = self.color_map_widget.currentData()
     return GradientColorMap(palette.lookup_table(),
                             thresholds=(self.color_low,
                                         max(self.color_high,
                                             self.color_low)),
                             span=(0., self._matrix_range))
Example #2
0
 def _colorize(self, var: Variable, data: np.ndarray) -> Tuple[np.ndarray, ColorMap]:
     palette = var.palette  # type: Palette
     colors = np.array(
         [[c.red(), c.green(), c.blue()] for c in palette.qcolors_w_nan],
         dtype=np.uint8,
     )
     if var.is_discrete:
         mask = np.isnan(data)
         data[mask] = -1
         data = data.astype(int)
         if mask.any():
             values = (*var.values, "N/A")
         else:
             values = var.values
             colors = colors[: -1]
         return data, CategoricalColorMap(colors, values)
     elif var.is_continuous:
         cmap = GradientColorMap(colors[:-1])
         return data, cmap
     else:
         raise TypeError
Example #3
0
 def color_map(self) -> GradientColorMap:
     return GradientColorMap(self.color_palette(),
                             (self.threshold_low, self.threshold_high),
                             0 if self.center_palette else None)
Example #4
0
 def test_colormap(self):
     w = HeatmapGridWidget()
     self.scene.addItem(w)
     w.setHeatmaps(self._Data["2-2"])
     w.setColorMap(GradientColorMap([[255] * 3, [0] * 3]))
     w.setColorMap(GradientColorMap([[255] * 3, [0] * 3], center=0))