I'm trying to sort image 1 I posted so that the densest points are more clearer, the link to an answer i'm using for the implementation indicates what i'm trying to achieve.
How can I make a scatter plot colored by density in matplotlib?
My code being:
# Calculate the point density: Saccade Orientation is an angle, Amplitude is supposed to be the Y value
xy = np.vstack([saccade_orientation_PP, saccade_amplitude_PP])
z = gaussian_kde(xy)(xy)
# Sort the points by density, so that the densest points are plotted last
idx = z.argsort()
x, y, z = np.array(saccade_orientation_PP)[idx], np.array(saccade_amplitude_PP)[idx], z[idx]
ax1 = plt.subplot(121, polar=True)
ax1.scatter(saccade_orientation_PP, saccade_amplitude_PP, c=z, edgecolor='', alpha = 0.75)
This is the result I get if I do not use the two lines of code that sort the points by density (commented out)
And this is the result when the sorting is implemented
I'm trying to achieve a similar goal as displayed in the answer in the link, so image 1 but cleaner but I do not understand why when I sort it I get the 2nd image below.
Thank you.