フィルターのクリア

Different colormaps and caxis on overlaying pcolorms

1 回表示 (過去 30 日間)
Pavel Inchin
Pavel Inchin 2023 年 8 月 14 日
コメント済み: Walter Roberson 2023 年 8 月 18 日
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 Center および File ExchangeOrange についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by