Given coordinates of [1,5,7,3,5,10,3,6,8] for matplotlib.pyplot, how do I highlight or colour different segments of the line. For instance, the coordinates 1-3 ([1,5,7,3]) in the list represent attribute a. How do I colour this bit of the line and mark it in the legend?
Edit: The list in question contains tens of thousands of elements. I’m trying to highlights specific sections of the list. From the answers so far, is it right to assume I must draw each segment one by one? There isn’t a way to say “select line segment from x1 coord to x2 coord, change colour of line”
Yes, you need to redraw the line, but you can clip the line so that only the part you are interested in is visible. To do this I create a rectangle covering the area that represents prop (a), then I use this to create a
clip_path.This results in:

When I plotted the line segment, I adjusted the transparent-ness using the
alphakeyword, which ranges from 0-1 or transparent to solid. I also made it a thicker line to extend beyond the original results.