Skip to content

Commit

Permalink
fix in case sample size is too small to create density colors
Browse files Browse the repository at this point in the history
  • Loading branch information
erdogant committed Jun 3, 2022
1 parent 0646046 commit 44daee1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scatterd/scatterd.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,14 @@ def gradient_on_density_color(X, c_rgb, labels):
else:
xy = np.vstack([X[idx, 0], X[idx, 1], X[idx, 2]])

if len(idx)>1:
try:
# Compute density
z = gaussian_kde(xy)(xy)
# Sort on density
didx = idx[np.argsort(z)[::-1]]
else:
except:
didx=idx

# order colors correctly based Density
density_colors[didx] = c_rgb[idx, :]
# plt.figure()
Expand Down

0 comments on commit 44daee1

Please sign in to comment.