I have constructed a scatter plot with x and y positions. Now I have an array with a third variable, density, and I want to assign a color for each point in my scatter plot depending on its density value. I know how to do it using the "scatter" task of matplotlib, for example:
x = [1,2,3,4]
y = [5,3,7,1]
density = [1,2,3,4]
map = plt.scatter(x, y, c=density)
colorbar = plt.colorbar(map)
Now, I would like to do the same using the "plot" function instead, something like:
map = plt.plot(x,y, '.', c=t)
I am trying to do an animation of a galaxy merger, and assign each particle a color depending of the density of that region. So far the code only works with the "plot" task, so I need to implement it that way, but all the examples I've found use the former way.
Thanks in advance!