I have a data set that looks like this
140400 70.7850 1
140401 70.7923 2
140402 70.7993 3
140403 70.8067 4
140404 70.8139 5
140405 70.8212 3
Where the first column corresponds to time (one second intervals between data points) and will be on the x axis, the second column corresponds with distance and will be on the y axis. The third column is a number (one through five) that is a qualification of the movement.
I want to make a plot that changes the color of the line between two points depending on what the number of the previous data point was. For example, I want the line to be red between the first and second data points because the qualification value was 1.
I've seen a lot of posts about making a sliding scale of colors depending on an intensity value, but I just want 5 colors: (red, orange, yellow, green, and blue) respectively.
I tried doing something like this:
plot(x,y,{'r','o','y','g','b'})
But with no luck.
Any ideas of how to approach this? Without looping if possible.
A
:colors='rmygb'; figure; hold on; for idx = 1 : size(A,1)-1, plot(A(idx:idx+1,1), A(idx:idx+1,2), colors(A(idx,3))); end
. Give that a go and see how it runs. BTW,o
is not supported as a colour sinceo
denotes a circular marker. I've replaced the colour with magenta. – Selenodontscatter
will give you nearly the same information, I don't guarantee it will be useful! – Hopping[i,j]=find(A==1)
, etc. This will give you the rows that have the third value equal to1
. Then, you could doscatter(x(i),y(j),'r'); hold on
and then repeat four more times. – Cholecystitis