Why does not m_pcolor draw some colors?
1 回表示 (過去 30 日間)
古いコメントを表示
Dear All, . I would like to draw my own data on Lambert Conformal Conic projected map using with m_map package. I tried the followings:
m_proj('lambert','longitude',[-34.748 60.8422],'latitude',[26.5861 71.8699]);
m_coast('patch',[1 .85 .7]);
m_pcolor(lon1,lat1,clim);
set(findobj('tag', 'm_pcolor'), 'edgecolor', 'none');
colormap(map);
>> h=colorbar;
labels={'ET'; 'BSk'; 'BWh'; 'BWk'; 'As'; 'Csa'; 'Cfa'};
h=colorbar;
set(h,'YTickMode','manual','YTick',[1:length(map)],'YTickLabelMode','manual','YTickLabel',labels);
where lon1, lat1 and clim 2D matrices (177x191), map is
m1= [101 255 255]./255;
m4= [207 170 85]./255;
m5= [255 207 0]./255;
m6= [255 255 101]./255;
m9= [255 154 154]./255;
m11= [0 254 0]./255;
m17= [0 48 0]./255;
map=[m1;
m4;
m5;
m6;
m9;
m11;
m17];
The clim matrix contains 7 values: 1, 4, 5, 6, 9, 11, 17 which have color m1, m4, m5, m6, m9, m11, m17. I attached the resulted map (Figure_sample). I do not understand why some colors are missing from the map? Could someone inform me what I did wrong?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149577/image.jpeg)
0 件のコメント
回答 (1 件)
Chad Greene
2015 年 10 月 1 日
I'm not sure if this is causing your problems, but your Ytick values should be
[1, 4, 5, 6, 9, 11, 17];
not
[1:length(map)]
2 件のコメント
Chad Greene
2015 年 10 月 2 日
Ah, of course! The values 1, 4, 5, 6, 9, 11, and 17 are not evenly spaced, so a colorbar linked to those values will not be evenly spaced. One way around this is to simply plot data that has evenly-spaced values. We'll call it catclim for categorical clim. The values in your clim matrix are
climvals = [1, 4, 5, 6, 9, 11, 17];
So create an empty catclim matrix:
catclim = NaN(size(clim));
And fill catclim with evenly-spaced numbers 1 through 7:
for k = 1:length(climvals)
catclim(clim==climvals(k)) = k;
end
Now plot
m_pcolor(lon1,lat1,catclim);
shading flat
cb = colorbar;
set(cb,'ytick',climvals,'yticklabel',labels)
参考
カテゴリ
Help Center および File Exchange で Mapping Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!