How can I have multiple colormaps in single map using mapping toolbox?

조회 수: 4 (최근 30일)
Cathy Garcia
Cathy Garcia 2016년 9월 7일
답변: Bjorn Gustavsson 2019년 5월 13일
I have a map with pcolorm for nutrient depth (range 0-400m) and contourm for temperature (range 0-30 deg Celcius) contours. I would like to use two colormaps, 'winter' for nutrient depth and 'hot' for temperature. The image attached is almost correct, but I would like a range of color for the contour lines. The examples shown here haven't worked for the map axis: https://www.mathworks.com/matlabcentral/answers/101346-how-do-i-use-multiple-colormaps-in-a-single-figure
if true
% code
% data
[lon2,lat2] = meshgrid(60:.5:140,32:-.5:-32);
xq = lon2; yq = lat2;
x = NutMap(:,2); y = NutMap(:,1); v = NutMap(:,3);v2 = NutMap(:,4); %size(NutMap) = 129x161
vq = griddata(x,y,v,xq,yq,'linear');tq = griddata(x,y,v2,xq,yq,'linear');
vq(landmask(lat2,lon2))=NaN; tq(landmask(lat2,lon2))=NaN;
contourmin = min(min(tq));
contourmax = max(max(tq));
pcolormin = min(min(vq));
pcolormax = max(max(vq));
figure;
hf = worldmap([-32 32],[60 140]);
colormap(hAxesP,winter);
pcolorPlot = pcolorm(xq,yq,vq);
cbP = colorbar(hAxesP,'Location','west');
caxis(hAxesP,[pcolormin pcolormax]);
hAxesCM = gca;
axis(hAxesCM,'off')
colormap(hAxesCM,hot);
contourmPlot = contourm(xq,yq,tq,20);
cbCM = colorbar(hAxesCM,'Location','east');
caxis(hAxesCM,[contourmin contourmax]);
linkaxes([hAxesP,hAxesCM]);
geoshow('landareas.shp', 'FaceColor', 'black');
end
  댓글 수: 2
Cathy Garcia
Cathy Garcia 2016년 9월 16일
If I can assist by editing the question with sample data, or clarifying anything, I can do so.
Irish Matt
Irish Matt 2019년 5월 12일
Still a great and unanswered question! Someone pls help :(

댓글을 달려면 로그인하십시오.

답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2019년 5월 13일
Give freezecolors a try, it has solved similar problems before, though not completely without fail.
HTH

Community Treasure Hunt

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

Start Hunting!

Translated by