Color scatter plot points depending on third value in matplotlib pyplot

259 Views Asked by At

I have a dataset with a million of points like:

1.0,9.5,-0.3
2.3,4.8,0.7
8.1,3.6,0.0
3.9,1.4,-0.1
4.7,5.3,0.0

and PyPlot code like

import pandas
import matplotlib.pyplot as plt

headers =  ['A','B','C']
df = pandas.read_csv('my_data.csv',names=headers)
df['x'] = df['A']
df['y'] = df['B']
# df['color'] = df['C']
plt.xlim(min(df['x'])/2, max(df['x'])*2)
plt.ylim(min(df['y'])/2, max(df['y'])*2)
plt.xlabel("A")
plt.ylabel("B")
plt.plot(df['x'], df['y'], 'o', ms = 0.2) 
plt.show()

I can plot points according to first and second column, but all points have the same color. How to tell PyPlot to color points based on the value in third column?