Skip to content

Commit a885536

Browse files
committed
fixed discrete color transform
1 parent be6491b commit a885536

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pyhdx/web/controllers.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,12 @@ def get_cmap_and_norm(self):
10181018
if self.mode == 'Discrete':
10191019
if len(self.values) != len(self.colors) - 1:
10201020
return None, None
1021-
cmap = mpl.colors.ListedColormap(self.colors)
1022-
norm = mpl.colors.BoundaryNorm(self.values[::-1], self.num_colors, extend='both') #todo refactor values to thd_values
1021+
cmap = mpl.colors.ListedColormap(self.colors[::-1])
1022+
values = self.get_values()
1023+
thds = sorted([values.min()] + self.values + [values.max()])
1024+
1025+
norm = mpl.colors.BoundaryNorm(thds,
1026+
self.num_colors, extend='neither') #todo refactor values to thd_values
10231027

10241028
elif self.mode == 'Continuous':
10251029
norm = norm_klass(vmin=np.min(self.values), vmax=np.max(self.values), clip=True)
@@ -1089,6 +1093,11 @@ def _update_num_values(self):
10891093
elif len(self.values) < self.num_colors - diff:
10901094
self._add_value()
10911095

1096+
if self.num_colors >= 5:
1097+
self.widgets['otsu_thd'].disabled = True
1098+
else:
1099+
self.widgets['otsu_thd'].disabled = False
1100+
10921101
self._update_bounds()
10931102
self.param.trigger('values')
10941103
self.update_box()

0 commit comments

Comments
 (0)