I have two columns of data, x and y. The y data takes the shape of the triangle wave below. As you can see, the triangle has 2 sections of positive gradient and 1 longer section with a negative gradient.

I would like to write a program that:
- Queries whether the current entry in an vertical array has a positive or negative gradient with respect to the successive entry in the array.
- Then, plots the y data against x, where y values with a positive gradient (and its respective x value) are plotted using one colour, and the negative points in another colour.
How is this best done in Python?
Does the trick for me!