forked from jooh/matlab-plotting
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlockaxisaspect.m
More file actions
19 lines (18 loc) · 737 Bytes
/
Copy pathlockaxisaspect.m
File metadata and controls
19 lines (18 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
% use manual axis positioning to achieve an identical (or similar) aspect
% ratio as was previously achieved by setting dataaspectratio or
% plotboxaspectratio. Matlab figure position tends to get very complicated
% when these are in manual mode so the typical use case for this function
% is to first set them to manual and then use this function to achieve a
% position-based setting that achieves a similar result.
%
% lockaxisaspect(ax)
function lockaxisaspect(ax)
for a = ax(:)'
orgbox = plotboxpos(a);
orgax = axis(a);
orgpos = get(a,'position');
set(a,'dataaspectratiomode','auto','plotboxaspectratiomode','auto');
set(a,'looseinset',get(a,'tightinset'));
axis(a,orgax);
set(a,'position',orgbox);
end