two colormaps with contourfm (or even contourf)

3 次查看(过去 30 天)
Hey all,
I have lat, lon, and elevation data. I'm trying to create a contourfm plot which has data below the sea in a blue colormap, and data above in a grey. I'm found suggestions for surface plots, but nothing for countour plots. Below is my code. I'm fine if this only works in contourf (in which case, to run the code one would need to swap the eleLat and eleLon data.
Also, to run this, one would need to load the .mat attached data attached data.
Does anyone have any suggestions?
latLongPlot = figure;
worldmap('world')
setm(gca,'fontsize',10,...
'fontweight','bold',...
'Origin',mean([-89 -85]),...
'mapLonLimit',[-89 -85],...
'maplatlimit',[41 44])
shoreEle = 55;
nContourShaded = 5;
% Plot above shoreline
idxGT = eleZ>=shoreEle-5;
eleZGT = eleZ;
eleZGT(~idxGT) = NaN;
[~,GT] = contourfm(eleLat,eleLon,eleZGT,nContourShaded,'linestyle','none');
% Grey colormap
colormap([linspace(0,0.5,nContourShaded*20)', linspace(0,0.5,nContourShaded*20)', linspace(0,0.5,nContourShaded*20)'])
hold on
% Plot below shoreline
idxLT = eleZ<=shoreEle;
eleZLT = eleZ;
eleZLT(~idxLT) = NaN;
LT = contourfm(eleLat,eleLon,eleZLT,nContourShaded,'linestyle','none');
% Blue colormap
colormap([zeros(nContourShaded*20,1), zeros(nContourShaded*20,1), linspace(0,0.6,nContourShaded*20)'])

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by