Filter löschen
Filter löschen

Different colormaps and caxis on overlaying pcolorms

1 Ansicht (letzte 30 Tage)
Pavel Inchin
Pavel Inchin am 14 Aug. 2023
Kommentiert: Walter Roberson am 18 Aug. 2023
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,

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 15 Aug. 2023
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 Kommentare
Pavel Inchin
Pavel Inchin am 18 Aug. 2023
Bearbeitet: Pavel Inchin am 18 Aug. 2023
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 am 18 Aug. 2023
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;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Orange finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by