필터 지우기
필터 지우기

How to fade contour lines without contour lines?

조회 수: 2 (최근 30일)
Mohammed
Mohammed 2014년 3월 23일
답변: DGM 2023년 11월 23일
Is there a way I can fade contour lines to the following code like the posted picture?!
Thanks!
F = scatteredInterpolant(Lon,Lat,EcIo,'natural','linear');
xlimit = linspace(min(Lon),max(Lon));
ylimit = linspace(min(Lat),max(Lat));
[Xq Yq] = meshgrid(xlimit,ylimit);
Vq = F(Xq,Yq);
contourf(Xq,Yq,Vq)
shading flat
colorbar('location','EastOutside')
xlabel('Longtitude','FontWeight','Bold')
ylabel('Latitude','FontWeight','Bold')

답변 (1개)

DGM
DGM 2023년 11월 23일
Not that this was ever answerable, but this replicates the given figure and provides two colorbars. I have no idea what "fading contour lines without contour lines" is even supposed to mean.
% get some placeholder data
[X Y Z] = peaks(100);
% create two axes
hax1 = axes;
hax2 = axes;
% draw the background pcolor in the lower axes
hp = pcolor(hax1,X,Y,Z);
hp.LineStyle = 'none';
cb1 = colorbar(hax1);
% and draw the overlay in the upper axes, set its alpha accordingly
nlevels = 9;
[~,hc] = contour(hax2,X,Y,Z,nlevels);
cb2 = colorbar(hax2);
cb2.Ticks = hc.LevelList;
% set colormaps
colormap(hax1,jet(256));
colormap(hax2,gray(nlevels-1));;
% store the position and limits because adjusting
% the colorbar will mess these up
axpos = get(hax1,'position');
xl = get(hax1,'xlim');
yl = get(hax1,'ylim');
% adjust the colorbars so they don't overlap
barl = 0.48;
cb1.Position(2) = cb1.Position(2)+cb1.Position(4)*(1-barl);
cb1.Position(4) = cb1.Position(4)*barl;
cb2.Position(4) = cb2.Position(4)*barl;
% reassert axes geometry so they match
set(hax1,'position',axpos,'xlim',xl,'ylim',yl);
set(hax2,'position',axpos,'color','none','xlim',xl,'ylim',yl);
% wrangle axes setup
linkaxes([hax1 hax2]);
set(hax2,'visible','off','xtick',[],'ytick',[]) % hide top axes decorations
set(hax2,'position',hax1.Position,'xlim',hax1.XLim,'ylim',hax1.YLim, ...
'plotboxaspectratio',hax1.PlotBoxAspectRatio); % try to align both axes

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by