Multiple surf woth different colorbar limits on a single plot

10 ビュー (過去 30 日間)
Leo Pio D'Adderio
Leo Pio D'Adderio 2023 年 5 月 20 日
コメント済み: Leo Pio D'Adderio 2023 年 5 月 23 日
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';

採用された回答

Walter Roberson
Walter Roberson 2023 年 5 月 20 日
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.
  1 件のコメント
Leo Pio D'Adderio
Leo Pio D'Adderio 2023 年 5 月 23 日
Thank you Walter, freezecolors makes the work!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by