Odd getrect(FIG) behavior with subplots (r2015b)
조회 수: 3 (최근 30일)
이전 댓글 표시
I am noticing an unusual behavior of getrect when passing a figure handle as the argument. e.g.
hFig1 = figure(1);
hAx1 = subplot(2,1,1);
plot(randn(100),randn(100),'.');
%hFig1.CurrentAxes is hAx1
hAx2 = subplot(2,1,2);
plot(randn(100),randn(100),'.');
%hFig1.CurrentAxes is now hAx2
%
%call getrect and select a rectangle on hAx1 (subplot 121)
>> r = getrect(hFig1)
r =
-2.9528 10.5594 6.8848 6.7133
%
%call getrect again and select another rectangle on hAx1 (subplot 121)
>> r = getrect(hFig1)
r =
-3.0138 -3.1389 6.0829 6.2778
Note the difference in r(2)//ymin - it seems that CurrentAxes property of hFig1 gets reassigned after the call to getrect.
Is is possible to either:
1. Interrupt getrect, reassign the CurrentAxes property of hFig1 to the subplot which has been clicked, then resume getrect?
or
2. Prevent the reassignment of the CurrentAxes property of hFig1 by getrect?
댓글 수: 2
Jan
2017년 10월 18일
Note the difference in r(2)/ymin
I note a difference, but why is this unexpected? You have selected two different rectangles. Why do you assume a relation to the CurrentAxes? Please explain the problem again.
채택된 답변
추가 답변 (1개)
Steven Lord
2017년 10월 19일
From the help for the getrect function:
"RECT = getrect(FIG) lets you select a rectangle in the current axes of figure FIG using the mouse.
RECT = getrect(AX) lets you select a rectangle in the axes specified by the handle AX."
If I understand correctly what you want, I think the best solution is to use hAx1 and hAx2 in your getrect calls instead of trying to fiddle with which axes is current in the figure hFig1.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!