Visual stacking order of objects and plotyy

조회 수: 8 (최근 30일)
Luca
Luca 2012년 5월 28일
편집: Adam Danz 2019년 8월 13일
Hi,
I have created a graph using the PLOTYY command,
[AX, H1, H2] = plotyy(Xdata, Y1data, Xdata, Y2data, 'loglog', 'loglog');
uistack(AX(1), 'up');
I want to annotate the graph using "line", and I want these lines to be behind the existing data.
I have tried the following code:
h_line = line(x, y);
uistack(h_line, 'bottom');
which places the line behind the data of the left y-axis (i.e. AX(1)), but still on top of the data of the right y-axis (i.e. AX(2)).
Does anyone know how to change the stacking order of annotation objects such that they lay behind all existing data made using PLOTYY?
Thanks,
Luca

채택된 답변

Walter Roberson
Walter Roberson 2012년 5월 29일
In order for a line drawn on one axes to appear behind a line drawn on another axes, the entire axes of the line must be behind the other axes.
You might end up having to use a third axes with the same position and axes limits as the first axes, but uistack()'d behind both other axes.
  댓글 수: 2
Luca
Luca 2012년 5월 29일
Thank you very much, it worked!
Luca
Luca 2012년 5월 29일
편집: Adam Danz 2019년 8월 13일
This is the code I used:
...
h_gca = gca;
gca_position = get(h_gca, 'Position');
AX_annotations = axes('Position', gca_position, 'Visible', 'off');
set(AX_annotations, 'XScale', get(h_gca, 'XScale'), ...
'YScale', get(h_gca, 'YScale'), ...
'XLim', get(h_gca, 'XLim'), ...
'YLim', get(h_gca, 'YLim'));
line(......)
uistack(AX_annotations, 'bottom');

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Two y-axis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by