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!