plotting values greater than threshold

240 ビュー (過去 30 日間)
shobhit mehrotra
shobhit mehrotra 2014 年 8 月 12 日
コメント済み: ishbish 2018 年 2 月 19 日
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 日
% 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 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 件)


Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by