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!