Different colormaps and caxis on overlaying pcolorms
1 次查看(过去 30 天)
显示 更早的评论
Good day,
I need to overlay two different datasets through pcolorm on the same figure and map (scatterm could also work). For each of them I want to have different caxis and colormaps.
The simplest code I am playing with is this:
close all
figure
worldmap([-90 90],[-180 180])
pcolorm(1:1:70,1:1:70,0.1:0.1:7) % I want to have caxis([0 1]) for this pcolorm and parula
pcolorm(-70:1:0,-70:1:0,0:1:70) % I want to have caxis([0 70]) for this pcolorm and jet
Thank you in advance for any suggestions,
采纳的回答
Walter Roberson
2023-8-15
Any one axes or mapping axes can only have one CLim property (the one affected by caxis), and can have only one color map.
pcolorm() and surfm() both return Surface objects. Surface objects accept RGB color data, so you can replace the color data with data that has been processed through rescale() to 0, 255, then uint8(), then ind2rgb() .
Note however that pcolorm() and surfm() require that the Z data be a grid that is length(lat) by length(long) . Your Z values, 0.1:0.1:7 is a vector not a 2D array, so it is not suitable for pcolorm() or surfm()
2 个评论
Walter Roberson
2023-8-18
CLIM_FOR_FIRST = [2 6];
CLIM_FOR_SECOND = [5 64];
figure
worldmap([-90 90],[-180 180])
s1 = pcolorm(1:1:70, 1:1:70, 0.1:0.1:7);
r1 = rescale(s1.CData, 0, 255, 'InputMin', CLIM_FOR_FIRST(1), 'InputMax', CLIM_FOR_FIRST(2));
r1 = uint8(r1);
mm = jet(256);
r1 = ind2rgb(r1,mm);
s1.CData = r1;
s2 = pcolorm(-70:1:0,-70:1:0,0:1:70);
r2 = rescale(s2.CData, 0, 255, 'InputMin', CLIM_FOR_SECOND(1), 'InputMax', CLIM_FOR_SECOND(2));
r2 = uint8(r2);
mm = winter(256);
r2 = ind2rgb(r2,mm);
s2.CData = r2;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!