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.
I found this topic, but it seems it doesn't work with pcolorm or scatterm.
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
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 个评论
Pavel Inchin
Pavel Inchin 2023-8-18
编辑:Pavel Inchin 2023-8-18
Thanks for helping with this! It seems work. However, I am not sure I understnad how to change CLim for each surface separately. I don't see CLim as a property for surface. Could you please suggest here?
close all
figure
worldmap([-90 90],[-180 180])
ax1 = pcolorm(1:1:70,1:1:70,0.1:0.1:7)
r1 = rescale(ax1.CData,0,255)
r1 = uint8(r1);
mm = jet(256);
r1 = ind2rgb(r1,mm);
ax1.CData = r1;
ax2 = pcolorm(-70:1:0,-70:1:0,0:1:70)
r2 = rescale(ax2.CData,0,255)
r2 = uint8(r2);
mm = winter(256);
r2 = ind2rgb(r2,mm);
ax2.CData = r2;
Walter Roberson
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 CenterFile Exchange 中查找有关 Orange 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by