Varying alpha or colors for pyplot markers based on data
<p>I have a fairly large data set containing positions of "star particles" that I've plotted using matplotlib. The data is organized into columns, three of which correspond to the x, y, and z coordinates. I plotted the x and y coordinates, but I want to be able to use the z coordinates as a kind of colormap for the particles. For example, particles with larger z coordinates have lower alpha or are colored differently. Currently my code looks like this:</p>

<pre><code>f = open(input_file)
line = f.readline()
line = f.readline()
px=[]
py=[]
pz=[]
for line in f:
    ldata = line.split()
    x = np.float(ldata[2])
    y = np.float(ldata[3])
    z = np.float(ldata[4])
px.append(x)
py.append(y)
pz.append(z)
plt.plot(px,py,'ro',alpha=0.1)
plt.savefig(output_file)
</code></pre>

<p>I'm new to python</p>