in zs[:,2] are numbers in my case such as from 1 to 5.
plt.scatter(zs[:,0], zs[:,1], c=zs[:,2], alpha=0.5)
What is the best way to map these numbers (from zs[:,2]) to specific colors?
in zs[:,2] are numbers in my case such as from 1 to 5.
plt.scatter(zs[:,0], zs[:,1], c=zs[:,2], alpha=0.5)
What is the best way to map these numbers (from zs[:,2]) to specific colors?
I did it in a similar way by means of panda lib (How can I convert numbers to a color scale in matplotlib?).
def col_map(x):
print(x)
if x == 0.0:
return "green"
if x == 1.0:
return 'red'
else:
return 'blue'
df = pd.DataFrame({"x":zs[:,0],"y":zs[:,1],"c":[col_map(x) for x in zs[:,2].tolist()]})
plt.scatter(df.x, df.y, color=df.c)