Skip to content

Commit

Permalink
Cap n_colors
Browse files Browse the repository at this point in the history
  • Loading branch information
JoerivanEngelen committed Oct 16, 2023
1 parent 425e7d0 commit e6f3edf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions imodqgis/widgets/unique_color_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ def get_colors_from_ramp_button(self) -> List[QColor]:
n_class = uniques.size
ramp = self.color_ramp_button.colorRamp()
n_colors = ramp.count()
# Cap n_colors at max 12, as for example some gradient colormaps have
# 255 stops. Too high values for n_colors create too subtle color
# shifts.
n_colors = np.min([n_colors, 12])

values_colors = self._get_tiled_normalized_midpoints(n_class, n_colors)
return [ramp.color(f) for f in values_colors]
Expand Down

0 comments on commit e6f3edf

Please sign in to comment.