How do I encode the color in a scatter plot, to color every point (x,y) with black when the variable curvature is 0, then fade to green the higher the curvature it gets and fade to red the negative it gets?
Asked
Active
Viewed 202 times
0
-
I don't think this is a proper way to post a question here. You might want to add in snippet/whole of your code or what you've tried so far. – officialaimm Aug 28 '17 at 16:54
-
I just found that this could be done using matplotlib.pyplot.scatter but I don't have any clue how to define a colormap – S.sonia Aug 28 '17 at 17:06
1 Answers
0
Your question seem to raise several issue.
First, you have to compute the curvature of your (x,y)
data. I suggest that you have a look here.
Then, perhaps you could have a look at all the available colomaps in matplotlib documentation. It may not be necessary to create your own colormap, though it is possible.
Finally, your code would be something like:
import numpy as np
import matplotlib.pyplot as plt
x = range(10)
y = np.random.rand(10) # generate random points
curvature = range(10) #compute your curvature here
plt.figure()
plt.scatter(x, y, s=20, c=curvature, cmap=plt.cm.seismic)
#perhaps you want to link points:
plt.plot(x,y)

Dneis
- 33
- 6