Odd getrect(FIG) behavior with subplots (r2015b)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Peter Cook
le 18 Oct 2017
Réponse apportée : Peter Cook
le 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 commentaires
Jan
le 18 Oct 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.
Réponse acceptée
Plus de réponses (1)
Steven Lord
le 19 Oct 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 commentaires
Voir également
Catégories
En savoir plus sur Subplots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!