I am using matplotlib to create the plots. I have to draw a line in a chart which color must be defined in function of each point. For example, I need a line where the points under 2000 are painted red, and points above 2000 are painted blue. How can I get this ? Do you know a similar solution or workaround to achieve it?
This is my sample code, which paint the hole line blue (default color I guess)
def draw_curve(points, labels):
plt.figure(figsize=(12, 4), dpi=200)
plt.plot(labels,points)
filename = "filename.png"
plt.savefig("tmp/{0}".format(filename))
figure = plt.figure()
plt.close(figure)
So, in the image below, I would like that values above the light blue horizontal line were painted in a different color than under values.
Thanks in advance.