필터 지우기
필터 지우기

two colormaps with contourfm (or even contourf)

조회 수: 2 (최근 30일)
Trevor Harris
Trevor Harris 2016년 10월 31일
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