MATLAB Answers


Changing color of the Matlab plot at different ranges

I want to have the below graph in two colors, the y-values > 600 should be red.
Right now I have a basic plot command.
I have read the litreature on this issue on the forums and previously asked questions - but none of them related to my problem

  댓글 수: 0

로그인 to comment.



답변 수: 1

Answer by Image Analyst
on 5 Apr 2019
 Accepted Answer

Try this:
indexes = yValues > 600;
plot(x(~indexes), y(~indexes), 'b.', 'MarkerSize', 10); % Plot in blue first.
hold on;
plot(x(indexes), y(indexes), 'r.', 'MarkerSize', 10); % Plot in red next.

  댓글 수: 1

works perfectly! Thanks, really appreciate it.

로그인 to comment.

Translated by