@@ -1126,16 +1126,38 @@ def _get_discrete_colors(self, c_data, subset):
11261126 c_data [np .isnan (c_data )] = len (self .palette )
11271127 c_data = c_data .astype (int )
11281128 colors = self .palette .qcolors_w_nan
1129- pens = np .array (
1130- [_make_pen (col .darker (self .DarkerValue ), 1.5 ) for col in colors ])
1131- pen = pens [c_data ]
1132- if self .alpha_value < 255 :
1129+ if subset is None :
1130+ pens = np .array (
1131+ [_make_pen (col .darker (self .DarkerValue ), 1.5 ) for col in colors ])
1132+ pen = pens [c_data ]
1133+ if self .alpha_value < 255 :
1134+ for col in colors :
1135+ col .setAlpha (self .alpha_value )
1136+ brushes = np .array ([QBrush (col ) for col in colors ])
1137+ brush = brushes [c_data ]
1138+ else :
1139+ subset_colors = [QColor (col ) for col in colors ]
1140+ a , b , c = 1.2 , - 3.2 , 3
1141+ x = 1 - self .alpha_value / 255
1142+ alpha = int (255 - 224 * (a * x ** 3 + b * x ** 2 + c * x ))
11331143 for col in colors :
1134- col .setAlpha (self .alpha_value )
1135- brushes = np .array ([QBrush (col ) for col in colors ])
1136- brush = brushes [c_data ]
1137-
1138- if subset is not None :
1144+ # col.setAlpha(int(224 - 0.7 * self.alpha_value))
1145+ col .setAlpha (alpha )
1146+ x = self .alpha_value / 255
1147+ alpha = 32 + int (224 * (a * x ** 3 + b * x ** 2 + c * x ))
1148+ for col in subset_colors :
1149+ # col.setAlpha(128 + 0.5 * self.alpha_value)
1150+ col .setAlpha (alpha )
1151+
1152+ pens , subset_pens = (
1153+ np .array (
1154+ [_make_pen (col .darker (self .DarkerValue ), 1.5 )
1155+ for col in cols ])
1156+ for cols in (colors , subset_colors ))
1157+ pen = np .where (subset , subset_pens [c_data ], pens [c_data ])
1158+
1159+ brushes = np .array ([QBrush (col ) for col in subset_colors ])
1160+ brush = brushes [c_data ]
11391161 black = np .full (len (brush ), QBrush (QColor (0 , 0 , 0 , 0 )))
11401162 brush = np .where (subset , brush , black )
11411163 return pen , brush
0 commit comments