フィルターのクリア

How to change the layer order of axes?

51 ビュー (過去 30 日間)
Csaba
Csaba 2021 年 11 月 6 日
編集済み: Adam Danz 2023 年 3 月 17 日
I have figure with tiledlayout, e.g. with (2,2) arrangement. The layer order will be tile-1, tile-2, tile-3, tile-4. Tile-4 is the uppermost while tile-1 is the lowermost layer. All 4 tiles have let's say a surf plot on it.
If I switch off clippings for each axes I can enlarge the content of all 4 axes. The enlarged figures, however, are behind each other, only the uppermost layer can be fully visible, all the others are, at least partly, behind other axes. How can I change interactively (I mean when I use the zoom for a specific axes) the layer order of the axes, in order to put the interesting axes to the uppermost layer and be able to fully see the enlarged content of that axes?
hfig=figure(12345);
tt=tiledlayout(2,2);
[X,Y,Z] = peaks(25);
CO(:,:,1) = zeros(25); % red
CO(:,:,2) = ones(25).*linspace(0.5,0.6,25); % green
CO(:,:,3) = ones(25).*linspace(0,1,25); % blue
ti1=nexttile(tt,1);
surf(X,Y,Z,CO);
ti1.Clipping='off';
ti2=nexttile(tt,2);
surf(X,Y,Z,CO);
ti2.Clipping='off';
ti3=nexttile(tt,3);
surf(X,Y,Z,CO);
ti3.Clipping='off';
ti4=nexttile(tt,4);
surf(X,Y,Z,CO);
ti4.Clipping='off';
%% Try to zoom axes!

採用された回答

Walter Roberson
Walter Roberson 2021 年 11 月 6 日
編集済み: Walter Roberson 2021 年 11 月 6 日
Set axes ButtonDownFcn callbacks, where the action is uistack(CurrentObject, 'top') . The CurrentObject should be the same as the first parameter passed to the callback function.
Note: uistack does not work for uifigure()
  4 件のコメント
Csaba
Csaba 2021 年 11 月 7 日
編集済み: Csaba 2021 年 11 月 7 日
Yes, that is true. But surf might cover all the axes. I tried to set both the surf (ax.Children) and axes (ax) ButtonDownFcn and it works quite well. So I will accept your answer.
However in this case the callback should be:
ax=gca;
uistack(ax,'top');
Adam Danz
Adam Danz 2023 年 3 月 17 日
編集済み: Adam Danz 2023 年 3 月 17 日
Starting in MATLAB R2023a you can use uistack to control the stacking order of ui components in a uifigure. See release notes.

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

その他の回答 (1 件)

Matt J
Matt J 2021 年 11 月 6 日
You can re-order the Children property of the TiledChardLayout,e.g.,
tt.Children=flip(tt.Children)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by