1313 QGraphicsPathItem
1414
1515from Orange .data import Table , Domain
16+ from Orange .preprocess import decimal_binnings
1617from Orange .projection .som import SOM
1718
1819from Orange .widgets import gui
@@ -209,7 +210,7 @@ def __init__(self):
209210 self .sizes = None
210211 self .cells = self .member_data = None
211212 self .selection = set ()
212- self .colors = self .bins = None
213+ self .colors = self .thresholds = None
213214
214215 box = gui .vBox (self .controlArea , box = True )
215216 hbox = gui .hBox (box )
@@ -341,7 +342,7 @@ def clear(self):
341342 self .data = self .cont_x = None
342343 self .sizes = None
343344 self .cells = self .member_data = None
344- self .colors = self .bins = None
345+ self .colors = self .thresholds = None
345346 if self .elements is not None :
346347 self .scene .removeItem (self .elements )
347348 self .elements = None
@@ -510,7 +511,7 @@ def _get_color_column(self):
510511 else :
511512 int_col = np .zeros (len (color_column ), dtype = int )
512513 int_col [np .isnan (color_column )] = len (self .colors )
513- for i , thresh in enumerate (self .bins , start = 1 ):
514+ for i , thresh in enumerate (self .thresholds , start = 1 ):
514515 int_col [color_column >= thresh ] = i
515516 return int_col
516517
@@ -714,16 +715,15 @@ def update_output(self):
714715
715716 def set_color_bins (self ):
716717 if self .attr_color is None :
717- self .bins = self .colors = None
718+ self .thresholds = self .colors = None
718719 elif self .attr_color .is_discrete :
719- self .bins = None
720+ self .thresholds = None
720721 self .colors = [QColor (* color ) for color in self .attr_color .colors ]
721722 else :
722723 col = self .data .get_column_view (self .attr_color )[0 ].astype (float )
723- # TODO: Use intelligent binning from #3896, when it's merged
724- self .bins = np .linspace (np .min (col ), np .max (col ), 6 )[1 :- 1 ]
724+ self .thresholds = decimal_binnings (col , min_bins = 4 )[0 ][1 :- 1 ]
725725 palette = ContinuousPaletteGenerator (* self .attr_color .colors )
726- nbins = len (self .bins ) + 1
726+ nbins = len (self .thresholds ) + 1
727727 self .colors = [palette [i / (nbins - 1 )] for i in range (nbins )]
728728
729729 def create_legend (self ):
@@ -738,10 +738,10 @@ def create_legend(self):
738738 else :
739739 sval = self .attr_color .repr_val
740740 names = \
741- [f"< { sval (self .bins [0 ])} " ] \
741+ [f"< { sval (self .thresholds [0 ])} " ] \
742742 + [f"{ sval (x )} - { sval (y )} "
743- for x , y in zip (self .bins , self .bins [1 :])] \
744- + [f"> { sval (self .bins [- 1 ])} " ]
743+ for x , y in zip (self .thresholds , self .thresholds [1 :])] \
744+ + [f"≥ { sval (self .thresholds [- 1 ])} " ]
745745
746746 items = []
747747 size = 8
0 commit comments