How do I make coloured scales from multiple graphs the same?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
My project is a 1 dimensional sediment transport model. My question is not about the model code. From the model I get 3D images and a scale (see attached photo). The scale is colour coded and I want the coloured scale for each graph to be the same no matter what the scales of the graph are. For example, I would like red to equal 80, even if one graph's scale is between 0 and 150 and another graph's scale is between 0 and 250. Thank you for considering my question :) I run R2015b.
I am a grad student working on a project in MATLAB. My abilities in MATLAB are very limited, the script and instructions on how to run the model were provided to me.
채택된 답변
Kelly Kearney
2016년 9월 22일
Just set the color axis limits to be the same on all of them:
ax(1) = subplot(2,2,1); % plot, etc.
ax(2) = subplot(2,2,2); % plot, etc.
set(ax, 'clim', [0 80]);
댓글 수: 3
Thank you Kelly :) Below I include my input and main files. Would you be able to have a look to see where I should insert the text you recommend? Thank kindly!
Here is my input file:
% 4 Sediment Flush - 2 week Sediment, 2 week flush, 2 week gravel, 2 week % flush % getInputs.m % parameters for 1D modeling % use percent to make a note within the code % semi-colon after command to stop matlab from displaying during model run
% initial parameters: L = 1200; %flume length, m M = 12; %number of cells for spatial discritization dx = L/M; qw = 1.82; %water discharge/width, m2/s qbTf_equi = 0; %background sediment input = to 0 or background if known qbTf_release1 = 0.0001503; %sand input rate, m2/s for 2 week sediment release qbTf_flush1 = 0; %2 week window to mobalise fine-grained sediment qbTf_release2 = 0; %gravel input rate, m2/s for 2 week sediment release qbTf_flush2 = 0; %gravel supply is 0 after inital feed rate etadI = 415; %base level, m Inter = 1; %intermittency Sfbi = 0.003; %0.00508; %initial slope dt = 100; %time step, seconds Mtoprint = 864; %number of steps until printout (every day) endT0 = 1209600; endT1 = 1209600 + endT0; %No. of seconds for 2 week period release of sand - last 2 weeks of May endT2 = 1209600 + endT1;% No. of seconds in 2 weeks for 2 week flush after 1st release - first 2 weeks of June endT3 = 1209600 + endT2; % No. of seconds in 2 weeks for gravel release after 1st flush - Last 2 weeks of June endT4 = 1209600 + endT3; % No. of seconds in 2 weeks for 2 week flush after 2nd release - First 2 weeks of July % runtime_hr = 336; %run time in hours (2 weeks) [hr]. tfinal = endT4; %end time, seconds Mfinal = tfinal/dt; %final time step EquationSelector = 2; %1 for parker, 2 for W-C g = 9.81; rho = 1000;
% new numerics for spatial sed flux derivatives % useParker = 1: use original upwinding coefficient scheme (au below)\ % useParker = 0: use one of the new schemes (kappa, limtype) % !kappa = 0.5 !quick scheme = 0.5, 2nd order upwind = -1 % !limtype = 1 !superbee = 1; Van Leer = 2; Van Albada = 3; 99 = high % resolution scheme exclusively, 999 = low resolution scheme exclusively
useParker = 1; kappa = 0.5; limtype = 2;
% Backwater calculation? % bw = 1: perform backwater calculation % bw = 0: normal flow approximation only % bw = 2: hecras mixed flow bw = 0;
%factor by which surface Ds90 is multiplied to obtain roughness height ks nk = 2;
%factor by which surface Ds90 is multiplied to obtain active layer %thickness La nactive = 1;
%coefficient in Manning-Strickler resistance relation (alpha-r) ar = 8.1;
%Submerged specific gravity of water (R) Rr = 1.65;
%Bed porosity, gravel (lambda-p) lps = 0.4;
%Upwinding coefficient for load spatial derivatives in Exner equation %(value > 0.5 suggested) %=0.5 implies central difference scheme %>0.5 implies upwinded scheme %<0.5 implies downwinded scheme au = 0.75;
%Coefficient for material transferred to substrate as bed aggrades (alpha) %the choice atrans=1 transfers pure surface layer material to the %substrate %the choice atrans=0 transfers pure bedload material to the substrate atrans = 0.5;
%initial grain size distributions di = [512 430.5 362.0 304.4 256.0 215.3 181.0 152.2 128.0 107.63 90.51 76.11 64.00 53.82 45.25 38.05 32.00 26.91 22.63 19.03 16.00 13.45 11.31 9.51 8.00 6.73 5.66 4.76 4.00 3.36 2.83 2.38 2.00 1.68 1.41 1.19 1.00 0.84 0.71 0.55 0.50 0.42 0.35 0.30 0.25 0.21 0.17 0.15 0.13]'; %diameters for gsds below, taken from grain size locations of 'DOTS' in fig. 7a. Setting the breakpoints - half or quarter phi plff1 = [100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 94.70 94.70 94.70 94.70 94.70 94.70 94.30 94.30 94.30 94.30 94.30 94.30 94.30 94.30 94.30 90.00 90.00 83.30 83.30 63.50 63.50 63.50 63.50 63.50 63.50 63.50 20.60 20.60 20.60 20.60 3.4 0.00]'; %feed: sand plff2 = [100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100 100 99.69 99.69 99.39 98.17 96.64 91.74 86.24 80.12 69.72 58.41 48.32 31.50 17.74 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]'; %feed: gravel Ffs = [100 99.5 98.5 98 97.6 96.1 94.6 93.2 91.2 89.3 84.9 80 74.1 68.8 62.4 56.6 49.8 42.4 30.2 16.1 3.4 1.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]'; %subsurface GSD, from 'DataforTed_Pulse and Bulk-FeedGSDs' (6:17,L), same for all runs. FfI = [100 99.5 98.5 98 97.6 96.1 94.6 93.2 91.2 89.3 84.9 80 74.1 68.8 62.4 56.6 49.8 42.4 30.2 16.1 3.4 1.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]'; %surface GSD
And here is my main file:
% new code to make things more streamlined
clear all
% read inputs inputFileName = 'MSR_input_4qbTf_0508_WIL15'; %input file name, omit .m extension eval(inputFileName);
% set up initial bed for i=1:M+1 xx(i) = dx*(i-1); eta(1,i) = etadI + L * Sfbi - xx(i) * Sfbi; surf_cdf(:,i) = FfI; end
% initialize output variables umax = round(tfinal/(Mtoprint*dt)+1); % nd = length(di); surf_pdf = zeros(M+1,nd-1,umax); trans_pdf = zeros(M+1,nd-1,umax); elev = zeros(M+1,umax); %bed elevation ws = zeros(M+1,umax); %water surface flux = zeros(M+1,umax); %bedload transport rate flux_kghr = zeros(M+1,umax); shearstress = zeros(M+1,umax); timesprinted = zeros(umax,1); normalWS = zeros(M+1,umax); %water surface using normal flow apporximation (similar to ws)
% start doing calculations Laold = zeros(1,M+1); %initialize Laold for first time step h = waitbar(0,'calculating....');
Finished = -1; u=0; j = 0; timestep = 0; time = 0;
while Finished == -1 j=j+1; w=0; DoneInnerLoop = -1; while DoneInnerLoop == -1 w=w+1; % semi-implicit would start here % determine feed and feed GSD (including pulse) if time <= endT0 qbTf = qbTf_equi; [D_pdf,plf] = cdf2pdf(di,plff1); elseif time <= endT1 qbTf = qbTf_release1; [D_pdf,plf] = cdf2pdf(di,plff1); %calculate pdf of sand sluiced from reservoir based on CDF supplied in input file ('plff1'). elseif time <= endT2 qbTf = qbTf_flush1; [D_pdf,plf] = cdf2pdf(di,plff1); %this line just here to create place holder array 'plf' for input to 'bedEvolveParker' below. Since you have established qbTf to be zero during this time period, this array will not influence calculations during this period. elseif time <= endT3 qbTf = qbTf_release2; [D_pdf,plf] = cdf2pdf(di,plff2); %calculate pdf of gravel input based on CDF supplied in input file ('plff2'). elseif time <= endT4 qbTf = qbTf_flush2; [D_pdf,plf] = cdf2pdf(di,plff2); %this line just here to create place holder array 'plf' for input to 'bedEvolveParker' below. Since you have established qbTf to be zero during this time period, this array will not influence calculations during this period. %lines 47-50 were unhidden for 2 different supply rates - hide %again for just 1 supply rate % elseif time <= endT3 % qbTf = qbTf3; % else % qbTf = qbTf4; end
% commented out because now calculated above. % [D_pdf,plf] = cdf2pdf(di,plff1); %feed pdf % [D_pdf,plf] = cdf2pdf(di,plff2); %feed pdf
% if(time >= pulsestarttime && time <= pulseendtime) % qbTf = qbTf_1 + pulsemag; % [~,plf] = cdf2pdf(di,plff); %feed pdf % [D_pdf,plf_pulse] = cdf2pdf(di,Ffpulse); %feed pdf % plf = (qbTf_1/qbTf).*plf + (pulsemag/qbTf).*plf_pulse; %pdf of combined feed + pulse % else % qbTf = qbTf_1; % [D_pdf,plf] = cdf2pdf(di,plff); %feed pdf % end
% hydraulic calculations
[S,H,tau,ustar,Hn] = hydraulics1d_bw(M,dx,eta,surf_cdf,di,rho,g,nk,qw,ar,xx,bw);
% sediment transport calculations
for i=1:M+1
switch EquationSelector
case 1
[qbT(1,i),load_cdf(:,i)] = find_load_parker_2(ustar(1,i),di,surf_cdf(:,i));
case 2
[qbT(1,i),load_cdf(:,i)] = find_load_WC_2(ustar(1,i),di,surf_cdf(:,i));
end
end
% set up La, F, fs, pl and calculate pdfs of GSDs
for i=1:M+1
D50surf(1,i) = finer_old(surf_cdf(:,i),50,di);
D84surf(1,i) = finer_old(surf_cdf(:,i),84,di);
%can add other statistical moments here is needed, also have to
%change generate_output.m
end
La = nactive .* D84surf./1000;
F = zeros(length(di)-1,M+1);
fs = zeros(length(di)-1,M+1);
pl = zeros(length(di)-1,M+1);
% plf = zeros(length(di)-1,M+1);
minD = min(di);
for i=1:M+1
[~,F(:,i)] = cdf2pdf(di,surf_cdf(:,i));
[~,fs(:,i)] = cdf2pdf(di,Ffs);
[D_pdf,pl(:,i)] = cdf2pdf(di',load_cdf(:,i));
end
% [D_pdf,plf] = cdf2pdf(di,plff); %feed pdf (commented b/c done
% above with pulse stuff now)
% provide initial conditions for output variables
if u==0
u=u+1;
generate_output;
end
% calculate new bed elevation and grain size
switch useParker
case 1
[F,eta,Laold] = bedEvolveParker(M,dx,au,qbT,qbTf,atrans,F,fs,pl,plf,eta,dt,Inter,lps,La,Laold,etadI,time);
case 0
[F,eta,Laold] = bedEvolveKappa(M,dx,kappa,limtype,D_pdf,qbT,qbTf,atrans,F,fs,pl,plf,eta,dt,Inter,lps,La,Laold,etadI,time);
end
% update surf_cdf
for i=1:M+1
[D2,surf_cdf(:,i)] = pdf2cdf(D_pdf,F(:,i),min(di));
end
surf_cdf = surf_cdf.*100;
% semi-implicit would end here
% update time, timestep
time = time+dt;
timestep = timestep+1;
if w==Mtoprint
DoneInnerLoop = 0;
end
if timestep==Mfinal
DoneInnerLoop = 0;
end
waitbar(timestep/Mfinal);
end
% print sequence
u=u+1; %set page number for 3d arrays, and column number for 2d arrays
generate_output;
if timestep>=Mfinal
Finished = 0;
close(h);
end
end
save Run1_test.mat;
%can type in plotting commands here
Aaaaaah!
I'm pretty sure plot-relevant stuff is actually in the generate_output script, not any of that code above.
Either attach that file, or cut-and-pase the relevant plotting-related stuff only.
If I had to take a blind guess, though, I'm going to guess that h is a figure handle, and the figure includes one of those subplots from your example image. In which case, add this after the call to generate_output.
hax = findall(h, 'type', 'axes');
set(hax, 'clim', [0 200]); % or whatever your preferred limits are
Unless of course the save-image-to-file step is also done in the generate_output script. In that case, you'll have to change the color limits before the saving is done.
Thank you kindly! I have someone helping me with this and your insights will be invaluable :) Very much appreciated
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
