How can I set the colours in contourcmap that the same levels values have same colour in different figures?

조회 수: 1 (최근 30일)
Dear All, I have two different matrix (rd_pr) which values are categirized in 10 classes by:
dif2=reshape(rd_pr,[size(rd_pr,1)*size(rd_pr,2),size(rd_pr,3)]);
dif1=dif2';
>> diff=repmat(NaN,1,length(dif1));
diff(find(-25 > dif1))=1;
diff(find(-15 > dif1 & dif1 >=-25))=2;
diff(find(-5 > dif1 & dif1 >=-15))=3;
diff(find(0 > dif1 & dif1 >=-5))=4;
diff(find(5>dif1& dif1 >= 0))=5;
diff(find(15>dif1& dif1 >= 5))=6;
diff(find(25>dif1& dif1 >= 15))=7;
diff(find(35>dif1& dif1 >= 25))=8;
diff(find(45>dif1& dif1 >= 35))=9;
diff(find(dif1 >= 45))=10;
IU=permute(reshape(diff, 1,464, 201), [1 2 3]);
IU2=permute(IU,[3 2 1]);
I would like to create a contourfm map from these matrices with common colorscale. I tried to do it by:
worldmap('Europe');
load coast;
plotm(lat, long, 'k');
clear lat long;
contourfm(latitude,longitude,IU2, 'LevelList',[1,2,3,4,5,6,7,8,9,10]);
contourcmap('jet', 'Colorbar', 'on', 'Location', 'horizontal')
I attched the resulted figures. The higher minimum value (3) in fig 2 has same colour as the lower minimum value (1) in fig 1. How can I set contourcmap that the same values have same colour? Thank you for your help in advance!

채택된 답변

Szabó-Takács Beáta
Szabó-Takács Beáta 2016년 6월 28일
Meantime I found a solution using with caxis:
v=[1,2,3,4,5,6,7,8,9];
worldmap('Europe');
load coast;
plotm(lat, long, 'k');
clear lat long;
contourfm(latitude,longitude,IU2,v);
caxis([1 10])
contourcmap('jet', 'Colorbar', 'on', 'Location', 'horizontal')

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by