color coding Xplot with othe property (New User)

BB,

I am Xploting two variables using

Plot(a,b,’o’)

Is it possible to color code the same plot with a 3rd property c instead of color we specify.

Also advise if it is possible to do 3D Xplot in matplotlib for variables a,b, & c and if possible to color code this 3d plot with 4th variable d.

Cheers

Sachin

Sachin Kumar Sharma, on 2011-03-23 02:44, wrote:

BB,

I am Xploting two variables using
Plot(a,b,'o')

Is it possible to color code the same plot with a 3rd property c instead of color we specify.

Also advise if it is possible to do 3D Xplot in matplotlib for variables a,b, & c and if possible to color code this 3d plot with 4th variable d.

Sashin,

use scatter(a,b,c=c, marker='o') to set the color of individual point.
There's even an 's' parameter with which you can individually set
the size of the marker.

npts = 100
a = np.random.rand(npts)
b = np.random.rand(npts)
c = np.random.rand(npts)
d = np.random.rand(npts)
plt.scatter(a,b,c=c,s=c*100, marker='o')

best,

···

--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7