Multiple surf woth different colorbar limits on a single plot
10 views (last 30 days)
Show older comments
Leo Pio D'Adderio
on 20 May 2023
Commented: Leo Pio D'Adderio
on 23 May 2023
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';
0 Comments
Accepted Answer
Walter Roberson
on 20 May 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.
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!