フィルターのクリア

How to create one common colorbar and colorscale for subplots

35 ビュー (過去 30 日間)
JMSE
JMSE 2021 年 11 月 16 日
コメント済み: JMSE 2021 年 11 月 17 日
Dear all,
I would like to add one common colorbar to all subplots shown below. Here it is very important that the all subplots should be on the same color scale. Subplot (4,2,4) with max 60 rain rate should then be showing much more yellow pixels than the other ones. I cannot find a way to do this within the loop below. Help is very much appreciated. :-) I am using the subplot function https://de.mathworks.com/matlabcentral/fileexchange/3696-subaxis-subplot to decrease the empty space between the subplots.
lat = load('latS.mat');
latS = lat.latS;
lon = load('lonS.mat');
lonS = lon.lonS;
rain = load('rain_test.mat');
rain_test = rain.rain_test;
figure
for i = 1 : 8;
subaxis(4,2,i, 'Spacing', 0.03, 'Padding', 0.0, 'Margin', 0.03);
pcolor(lonS,latS,rain_test(:,:,i));shading flat
%geoshow('landareas.shp', 'facecolor', 'k');
xlabel('longitude (°)'); ylabel('latitude (°)');
%h=colorbar;
%set(get(h,'ylabel'),'String','Rain rate (mm/h)');
hold on
plot(179.5,-14.2,'r*')
axis tight
axis off
end
Unrecognized function or variable 'subaxis'.

採用された回答

Chunru
Chunru 2021 年 11 月 17 日
You need to add in the following inside the loop for each subplot:
caxis([0 60]); % adjust the number 60 or find the value from all data first
  2 件のコメント
JMSE
JMSE 2021 年 11 月 17 日
Perfect; thanks!
JMSE
JMSE 2021 年 11 月 17 日
And do you know how to create one common colorbar for all of the plots? I now manage to have a common scale, however the colorbars are still one for each plot.
Max=max(rain_test,[],'all') %find max_value of the whole 3D-array
Min=min(rain_test,[],'all') %find min_value of the whole 3D-array
figure
for i = 1 : 8;
subaxis(4,2,i, 'Spacing', 0.03, 'Padding', 0.0, 'Margin', 0.03);
pcolor(lonS,latS,rain_test(:,:,i));shading flat
%geoshow('landareas.shp', 'facecolor', 'k');
xlabel('longitude (°)'); ylabel('latitude (°)');
%find
caxis([Min Max]);
h=colorbar;
set(get(h,'ylabel'),'String','Rain rate (mm/h)');
hold on
plot(179.5,-14.2,'r*')
axis tight
axis off
end

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by