필터 지우기
필터 지우기

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 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