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 5, 2021
1 parent 67c247f commit 0b73ef4
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions Orange/widgets/visualize/owscatterplotgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,16 +1126,31 @@ 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]
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))
for col in subset_colors:
col.setAlpha(128 + 0.5 * self.alpha_value)

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 0b73ef4

Please sign in to comment.