Odd getrect(FIG) behavior with subplots (r2015b)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Peter Cook
am 18 Okt. 2017
Beantwortet: Peter Cook
am 24 Jan. 2018
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 Kommentare
Jan
am 18 Okt. 2017
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.
Akzeptierte Antwort
Weitere Antworten (1)
Steven Lord
am 19 Okt. 2017
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 Kommentare
Siehe auch
Kategorien
Mehr zu Subplots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!