color map with specific range
Show older comments
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
Answers (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
.
Categories
Find more on Color and Styling 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!
