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

Respuestas (1)

Star Strider
Star Strider el 22 de Ag. de 2023
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
.

Categorías

Más información sobre Color and Styling en Centro de ayuda y File Exchange.

Productos

Versión

R2022a

Etiquetas

Preguntada:

el 22 de Ag. de 2023

Respondida:

el 22 de Ag. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by