im trying to plot values greater than a threshold in a different color. for example i want to plot values greater than 100 in the image in red

 채택된 답변

Image Analyst
Image Analyst 2014년 8월 12일

4 개 추천

% Create sample data.
y = randi(160, 1, 40); % Array of random numbers
x = 1 : length(y);
% Plot everything with blue spots and blue lines between them.
plot(x, y, 'bo-', 'LineWidth', 2, 'MarkerSize', 7);
grid on;
% Now define a threshold.
threshold = 100;
moreThanThreshold = y > 100; % Logical indexes.
% Extract those over the threshold into new arrays.
over_x = x(moreThanThreshold);
over_y = y(moreThanThreshold);
% Now plot those over 100 with red stars over the first set of points.
hold on; % Important so you don't blow the first plot away.
plot(over_x, over_y, 'r*', 'LineWidth', 2, 'MarkerSize', 13);

댓글 수: 3

ishbish
ishbish 2018년 2월 12일
This is great, but only seems to work as a threshold on the y-axis (like a horizontal 'cutoff point').
I need a cutoff point along a certain slope. E.g. as opposed thresholding my data at the line x=100, I might want it thresholded at the line y=3x. How could I go about this?
Thanks for any help!
Image Analyst
Image Analyst 2018년 2월 12일
Start a new question and attach some actual data, and if possible a picture of what you'd like to see.
ishbish
ishbish 2018년 2월 19일
I ultimately decided to apply a rotation matrix to my data and then just do it as described above, much easier! Thank you for the advice though.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

질문:

2014년 8월 12일

댓글:

2018년 2월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by