Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: AlsCdz <cadez_ales@si...>  20081216 02:23:19

Hello, i need you help! I want to draw a plot with circles, which are coloured according to size. So let's say we have a list=[1,3,5,7] that would give me four circles, first very small, second bigger and so on. Now i need a way to "convert" integers to color value which would match matplotlib.cm.spectral values. I hope you understand what i want to do, something like: ( http://zoonek2.free.fr/UNIX/48_R/g208.png http://zoonek2.free.fr/UNIX/48_R/g208.png ) I posted only the "important" bits of code: listData = [[2,5,1],[2,4,15],[13,2,1],[1,10,2]] cmap = mpl.cm.spectral norm = mpl.colors.Normalize(vmin=1, vmax=15) listA = ([i for i in range(len(listData))]) for a in range(len(listData)): listB = ([a for i in range(len(listData[0]))]) area = ([listData[a][i]*100 for i in range(len(listData[a]))]) color = ([listData[a][i]*100 for i in range(len(listData[a]))]) plt.scatter(listA,listB,s=area, cmap=cmap, c=??what to put here???) cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=cmap, norm=norm, orientation='vertical') I hope someone could help me! thank you very much ales  View this message in context: http://www.nabble.com/inttomatplotlib.colormapsvaluetp21026017p21026017.html Sent from the matplotlib  users mailing list archive at Nabble.com. 
From: Eric Firing <efiring@ha...>  20081216 18:22:06

AlsCdz wrote: > Hello, i need you help! > I want to draw a plot with circles, which are coloured according to size. So > let's say we have a list=[1,3,5,7] that would give me four circles, first > very small, second bigger and so on. > Now i need a way to "convert" integers to color value which would match > matplotlib.cm.spectral > values. > > I hope you understand what i want to do, something like: ( > http://zoonek2.free.fr/UNIX/48_R/g208.png > http://zoonek2.free.fr/UNIX/48_R/g208.png ) > > I posted only the "important" bits of code: > > > listData = [[2,5,1],[2,4,15],[13,2,1],[1,10,2]] > cmap = mpl.cm.spectral > norm = mpl.colors.Normalize(vmin=1, vmax=15) > > listA = ([i for i in range(len(listData))]) > for a in range(len(listData)): > listB = ([a for i in range(len(listData[0]))]) > area = ([listData[a][i]*100 for i in range(len(listData[a]))]) > color = ([listData[a][i]*100 for i in range(len(listData[a]))]) > plt.scatter(listA,listB,s=area, cmap=cmap, c=??what to put here???) > > cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=cmap, norm=norm, > orientation='vertical') > > > > I hope someone could help me! > > thank you very much > ales radius = np.arange(10) area = np.pi*radius**2 x = np.random.rand(10) y = np.random.rand(10) cmap = plt.get_cmap('spectral') plt.scatter(x, y, s=area, c=radius, cmap=cmap) plt.colorbar() I think the above illustrates what you need. Eric 
From: Eric Firing <efiring@ha...>  20081217 06:11:41

Aleš Čadež wrote: > First of all, thanks for helping me. What you wrote is not exactly what > i need. Let me show you an example: > > > > > > Now here are different size circles (biggest grey is »size=8«, other two > are »size=4«, and blue circles are size 2 and 1). I would like to color > them according to colorbar (size=1 = blue, size=4 = green, size = 8 = red) > > > > In your example there is random color to the circle size, i want the > size to match the color. I think my randomizing of the position is throwing you off. Here is a version that I think makes it more clear that the size (radius) is matching the color: radius = np.arange(10) area = np.pi*radius**2 x = radius y = area cmap = plt.get_cmap('spectral') plt.scatter(x, y, s=area, c=radius, cmap=cmap) plt.colorbar() Eric 
Sign up for the SourceForge newsletter:
No, thanks