# How to fade contour lines without contour lines?

3 Ansichten (letzte 30 Tage)
Mohammed am 23 Mär. 2014
Beantwortet: DGM am 23 Nov. 2023
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)
colorbar('location','EastOutside')
xlabel('Longtitude','FontWeight','Bold')
ylabel('Latitude','FontWeight','Bold')
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

DGM am 23 Nov. 2023
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
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
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Contour Plots finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by