How to fade contour lines without contour lines?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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')
0 commentaires
Réponses (1)
DGM
le 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
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
0 commentaires
Voir également
Catégories
En savoir plus sur Colormaps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!