bring to front in dual plot

17 views (last 30 days)
AHMAD
AHMAD on 23 Jul 2025
Edited: dpb on 26 Jul 2025
In dual plot, how to bring the left plot to front, I try uistack but didn't work
  9 Comments
dpb
dpb on 24 Jul 2025
Edited: dpb on 25 Jul 2025
@Adam Danz says "changing the child order can be a strategy for controling stacking order in general. "
Yeah, I learned about that from there having been a blog illustrating it at some distant time in the past; couldn't begin to say who or when, any more.
Your demo illustrates the point I made earlier about there being only one child/axes rather than multiple so that there isn't anything to sort/rearrange to affect stacking order.
My only thought was whether if one could apply the same concept to the axes order instead of lines it might just trigger a refresh of both axes.
dpb
dpb on 26 Jul 2025
Edited: dpb on 26 Jul 2025
yyaxis right
plot(1:5)
yyaxis left
plot(5:-1:1)
hAx=gca
hAx =
Axes with properties: YAxisLocation: 'left' YAxis: [2×1 NumericRuler] YLim: [1 5] XLim: [1 5] XScale: 'linear' YScale: 'linear' Position: [0.1300 0.1100 0.7750 0.8150] Units: 'normalized' Use GET to show all properties
hAx.YAxis
ans =
2×1 NumericRuler array: NumericRuler NumericRuler
hAx.YAxis(1)==hAx.YAxis(2)
ans = logical
0
yyaxis is a special beastie, indeed; being one axes but with two selectable independent NumericRuler Y-axes.
For comparison, the venerable plotyy
x=1:5;
hAx=plotyy(x,flip(x),x,x)
Warning: InteractionOptions is not supported for legacy exploration modes.
Warning: InteractionOptions is not supported for legacy exploration modes.
hAx =
1×2 Axes array: Axes Axes
hAx==gca
ans = 1×2 logical array
1 0
creates two completely independent axes, overlaying the second on top of the first.
Either way, there's no convenient way to change the stacking order; while one can
hAx=flip(hAx);
hAx==gca
ans = 1×2 logical array
0 1
and indeed, change the storage order ot the two axes since now the handle array is just a graphics object array like any other, that has no effect on the existing stacking order.
PS. I'm not sure what the warning is about; that doesn't happen locally, but I'm still with R2021b/R2022b here.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!