Reputation: 1770
I want to make a plot such that for all y
values greater than some y0
, the plot will be shown in red. For all other values, it will be shown in blue. Is this possible in MATLAB? This would help draw distinct parts of a plot in different colors/settings for different conditions. I'm looking for something like
plot(x,y,{y>y0,'-r'})
.
Upvotes: 0
Views: 1290
Reputation: 12514
This question does not define what should happen at the limits.
But one good try is:
y1=y;
y1(y<=y0)=NaN;
plot(x,y,'b', x,y1,'r');
Upvotes: 0
Reputation: 823
you can separate the value which are greater than y0 and then plot the graph once for values less than y0 and second time for values greater than y0 by use of "hold on".
http://www.mathworks.com/help/matlab/ref/hold.html
Upvotes: 0