How do I plot countours with consistent color map?
조회 수: 3 (최근 30일)
이전 댓글 표시
I am trying to generate a set of contour plots. Each plot contains 2 axes showing l/h and r/h data which I want to be able to compare using a single colorbar/colormap. However, I keep getting mismatched colorbars and I m not sure what I am doing wrong. As you can see from the attached plot, my range and ticks match but the colormap is all wonky.
Please advise if you see my error.
Inputs
x = monotonically increasing vector of n x locations
y = monotonically increasing vector of m y locations
p1 = m x n array of l/h pressure values
p2 = m x n array of r/h pressure values
Code
% Find Plot Limits
mx=ceil(max(max[p1,p2])); % find max pressure in l/h and r/h data sets
mn=floor(min(min([p1,p2])); % find min pressure in l/h and r/h data sets
delta=(mx-mn)/40; % delta for contour plot
% Create Figure
figure1=figure('Color', [1 1 1]);
% Axis 1
axes1=axes('Parent', figure 1,'BoxStyle','full','Layer','top','visible','off'); %create l/h axis
hold(axes1,'on')
contour (x,y,p1,[mn:delta:mx],'Fill', 'on');
set (colorbar, 'Limits', [mn,mx])
% Axis 2
axes2=axes('Parent', figure 1,'BoxStyle','full','Layer','top','visible','off'); %create r/h axis
hold(axes2,'on')
contour (x,y,p2,[mn:delta:mx],'Fill', 'on');
set (colorbar, 'Limits', [mn,mx])
댓글 수: 3
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Colormaps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!