python - Matplotlib cmap color-to-number mapping -


i'm parsing data , plotting matplotlib. i've produced following graphclustering of income following code:

n = 10000 num_clusters = 8  cluster_values = kmeans(data, num_clusters=num_clusters) y = np.random.normal(1, 0.1, n)  py.figure(num=1, figsize=figsize) py.scatter(data[:n], y, c=cluster_values[:n]) py.title("%s clustering of first %d data points %d clusters" % (data_label, n, num_clusters)) py.show() 

i'm taking income data, running through kmeans cluster , plotting data colormap of cluster index of each point. figure out relationship between colors , cluster index. i'd know that, example, blue = 2 , green = 0. put way, want know color point assigned based on it's cluster_value.

as code, n=10000 there decrease number of points (i have ~100000, slows down computer) , np.random.normal there spread out data.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -