Skip to content

Commit

Permalink
Scatterplot: Use opacity for contrast
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Nov 6, 2021
1 parent 67c247f commit d6261dd
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions Orange/widgets/visualize/owscatterplotgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,16 +1126,38 @@ def _get_discrete_colors(self, c_data, subset):
c_data[np.isnan(c_data)] = len(self.palette)
c_data = c_data.astype(int)
colors = self.palette.qcolors_w_nan
pens = np.array(
[_make_pen(col.darker(self.DarkerValue), 1.5) for col in colors])
pen = pens[c_data]
if self.alpha_value < 255:
if subset is None:
pens = np.array(
[_make_pen(col.darker(self.DarkerValue), 1.5) for col in colors])
pen = pens[c_data]
if self.alpha_value < 255:
for col in colors:
col.setAlpha(self.alpha_value)
brushes = np.array([QBrush(col) for col in colors])
brush = brushes[c_data]
else:
subset_colors = [QColor(col) for col in colors]
a, b, c = 1.2, -3.2, 3
x = 1 - self.alpha_value / 255
alpha = int(255 - 224 * (a * x ** 3 + b * x ** 2 + c * x))
for col in colors:
col.setAlpha(self.alpha_value)
brushes = np.array([QBrush(col) for col in colors])
brush = brushes[c_data]

if subset is not None:
# col.setAlpha(int(224 - 0.7 * self.alpha_value))
col.setAlpha(alpha)
x = self.alpha_value / 255
alpha = 32 + int(224 * (a * x ** 3 + b * x ** 2 + c * x))
for col in subset_colors:
# col.setAlpha(128 + 0.5 * self.alpha_value)
col.setAlpha(alpha)

pens, subset_pens = (
np.array(
[_make_pen(col.darker(self.DarkerValue), 1.5)
for col in cols])
for cols in (colors, subset_colors))
pen = np.where(subset, subset_pens[c_data], pens[c_data])

brushes = np.array([QBrush(col) for col in subset_colors])
brush = brushes[c_data]
black = np.full(len(brush), QBrush(QColor(0, 0, 0, 0)))
brush = np.where(subset, brush, black)
return pen, brush
Expand Down

0 comments on commit d6261dd

Please sign in to comment.