set data point color based on y value

7 views (last 30 days)
Robert Jones
Robert Jones on 5 Mar 2012
I am trying to get the data on a plot colored. I would prefer to set the color but dont know how to set color for a range of data. I guess I could either plot point by point and check the y value and change color accordingly or just graph it all then set the color. Ultimately I would like to graph values less than one in red, values of 1.0-1.08 in green and values over 1.08 in yellow.
pctTarget = coilData(:,17);
plot(pctTarget,'g');
hold on
plot(pctTarget(1:66),'r');
plot(pctTarget(766:4775),'Color','y');
axis([1,4775,0.5,1.5])
hold off
Thanks, Bob

Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!