Multiple surf woth different colorbar limits on a single plot

10 Ansichten (letzte 30 Tage)
I am plotting three surfaces at different Z values on a single plot. The code works but I need the different colorbar limits. At the moment all the three surface keep the colorbar limits of the last surface plotted. Any suggestion to have three different colorbar limits?
I am attaching the code with the matrices needed to make the plot.
z=[200;250;400];
CX=[230,236;224,230;218,224];
figure;
for i=1:size(M,3)
MAT=squeeze(M(:,:,i));
Z=ones(size(MAT))*z(i);
fl=surf(lon,lat,Z,MAT);
fl.LineStyle='none';
hold on;
clim(CX(i,:));
xlim([0 20]);
ylim([30 45]);
end
ax=gca;
ax.ZDir='reverse';

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 20 Mai 2023
You appear to be using older-style graphics (in particular not App Designer / uifigure)
In this situation you can call the File Exchange Contribution freezeColors https://www.mathworks.com/matlabcentral/fileexchange/7943-freezecolors-unfreezecolors
You would plot the first surface with the first color axes limits, use freezeColors to convert it to RGB, plot the second surface with the second color axes limits, use freezeColors again to convert that part to RGB, then plot the third surface with the third color axes limits.
This process does not provide for dynamic manipulation of the color axes limits, but at least it works.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by