How to fade contour lines without contour lines?

2 次查看(过去 30 天)
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 中查找有关 Colormaps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by