color map with specific range

I have a scatter as shown in the fifure below. i want to do is if y value biger than 1 has a red color and above 3 is yellow and above 4 is red. how can i do it . thanks in advance

답변 (1개)

Star Strider
Star Strider 2023년 8월 22일

1 개 추천

I used 'filled' here because otherwise the yellow points may be difficult to see —
figure
imshow(imread('tri.jpg'))
x = 1:85;
y = 6*rand(size(x));
th = [1 3 4 max(y(:))];
c = 'ryr';
figure
hold on
scatter(x, y, 25, 'b', 'filled')
for k = 1:numel(c)
Lv = y > th(k) & y <= th(k+1);
scatter(x(Lv), y(Lv), 25, c(k), 'filled')
end
hold off
.

카테고리

도움말 센터File Exchange에서 Color and Styling에 대해 자세히 알아보기

제품

릴리스

R2022a

태그

질문:

2023년 8월 22일

답변:

2023년 8월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by