python - Visualization of scatter plots with overlapping points in matplotlib -
i have represent 30,000 points in scatter plot in matplotlib. these points belong 2 different classes, want depict them different colors.
i succeded in doing so, there issue. points overlap in many regions , class depict last visualized on top of other one, hiding it. furthermore, scatter plot not possible show how many points lie in each region. have tried make 2d histogram histogram2d , imshow, it's difficult show points belonging both classes in clear way.
can suggest way make clear both distribution of classes , concentration of points?
edit: more clear, link data file in format "x,y,class"
one approach plot data scatter plot low alpha, can see individual points rough measure of density. (the downside approach has limited range of overlap can show -- i.e., maximum density of 1/alpha.)
here's example:
as can imagine, because of limited range of overlaps can expressed, there's tradeoff between visibility of individual points , expression of amount of overlap (and size of marker, plot, etc).
import numpy np import matplotlib.pyplot plt n = 10000 mean = [0, 0] cov = [[2, 2], [0, 2]] x,y = np.random.multivariate_normal(mean, cov, n).t plt.scatter(x, y, s=70, alpha=0.03) plt.ylim((-5, 5)) plt.xlim((-5, 5)) plt.show()
(i'm assuming here meant 30e3 points, not 30e6. 30e6, think type of averaged density plot necessary.)
Comments
Post a Comment