how to use color sets in maps by defining intervals in matlab (for example: lower than 10 , between 10 and 50 , between 50 and 200, between 200 and 1000, greater than 1000). thanks

조회 수: 1 (최근 30일)
how to use color sets in maps by defining intervals in matlab (for example: lower than 10 , between 10 and 50 , between 50 and 200, between 200 and 1000, greater than 1000). thanks

채택된 답변

Image Analyst
Image Analyst 2019년 4월 10일
Maybe like
cMap = zeros(1000, 3);
cMap(1:9, :) = [.4, .7, .3]; % Whatever color you want.
cMap(10:50, :) = [.8, .1, .6]; % Whatever color you want.
cMap(50:200, :) = [.6, .37, .8]; % Whatever color you want.
cMap(200:end, :) = [15, .2, .58]; % Whatever color you want.
colormap(cMap);
colorbar;
  댓글 수: 2
mina massoud
mina massoud 2019년 4월 10일
thank you for risponding
but i mean if i have a matrix like this
C = [0 2 4 6; 8 10 12 14; 16 18 20 22];
imagesc(C)
colorbar
and i need to put intervals for the value of the matrix
like from [0:4] is a red color
[5:10] is blue color
[11:20] is green color
maggior than 20 is black
for example
thank you
Image Analyst
Image Analyst 2019년 4월 10일
Try this:
C = [0 2 4 6; 8 10 12 14; 16 18 20 21]
imagesc(C)
colorbar
% and i need to put intervals for the value of the matrix
% like from [0:4] is a red color
% [5:10] is blue color
% [11:20] is green color
% maggior than 20 is black
cmap = zeros(22, 3);
cmap(1:5, :) = repmat([1, 0, 0], 5, 1); % 0 to 4 is red
cmap(6:11, :) = repmat([0, 0, 1], 6, 1); % 5 to 10 is blue.
cmap(12:21, :) = repmat([0, 1, 0], 10, 1); % 11 to 20 is green.
cmap(22, :) = [0, 0, 0]; % more than 20 is black.
colormap(cmap);
colorbar;
impixelinfo; % Let user mouse around and see image values.
0000 Screenshot.png

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

추가 답변 (1개)

Kelly Kearney
Kelly Kearney 2019년 4월 10일
What are you trying to do with those color intervals? Create a colorbar? Or perhaps a contour plot? If the latter, you can try using my contourfcmap function; it's designed to allow precise color level definition like this.

카테고리

Help CenterFile Exchange에서 Orange에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by