Pawel, on 2010-12-18 20:04, wrote: > Hi, > > I am a new user of matplotlib so maybe my question is elementary, but > have not been able to find an answer to my problem in the archive. > > I would like to make a 2D plot of colored points of 3D data (clusters). > My data looks like this: > > 11837.2120 -0.0858 2.0000 > 23975.2120 -0.0672 2.0000 > 37609.2120 -0.0306 2.0000 > 53263.9800 -0.0690 2.0000 > 72106.6760 0.2708 1.0000 > 92674.6760 -0.0129 3.0000 > 116758.676 -0.1245 3.0000 > ... > > So I need to plot the first and second column as points on the x-y axis > and color the points according to the numbers in the third column (which > are integers ranging from 1 to5). > > I'd appreciate any help. I realize something so typical should be > somewhere in the documentation but I was not able to find it.
Hi Paul, welcome to matplotlib! So you need to read in those columns somehow (as numpy arrays, or lists), but once you've got that, it's just a matter of initiating a 3d plot, and calling scatter with the three columns. take a look at this example and it's source code: http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/tutorial.html#scatter-plots for your purposes, the code will be something like: from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter(x,y,z) best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
signature.asc
Description: Digital signature
------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users