My starting point is How to modify 2d Scatterplot to display color based off third array in csv file?
I have a dataset
x y time
1 2 10:24:30
2 1 15:30:12
So the idea is at the point of time 10:24:30
the object is at location (1,2).
I want to display a scatter plot with the color of points as time info (right now, hour is enough, i.e. there will be 24 colors according to 24 hours per day).
How could I do that, and also display a legend to explain what color corresponds to what time?
Minimal example:
fig = plt.figure(figsize=(6,6))
ax = fig.add_subplot(111)
ax.set_title("X vs Y AVG",fontsize=14)
ax.set_xlabel("XAVG",fontsize=12)
ax.set_ylabel("YAVG",fontsize=12)
ax.grid(True,linestyle='-',color='0.75')
x = np.random.random(30)
y = np.random.random(30)
z = np.random.random(30) * 24
# scatter with colormap mapping to z value
ax.scatter(x,y,s=20,c=z, marker = 'o', cmap = cm.jet );
plt.show()
The color