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