This is a static copy of a profile reportHome
linkaxes (1 call, 0.153 sec)
Generated 05-Aug-2011 13:00:48 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/matlab/graphics/linkaxes.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
89 | hlink = linkprop(ax,'XLim'); | 1 | 0.077 s | 50.0% |  |
83 | drawnow; | 1 | 0.044 s | 28.6% |  |
61 | Idup = setdiff(1:length(ax),I)... | 1 | 0.022 s | 14.3% |  |
107 | end | 3 | 0 s | 0% |  |
106 | setappdata(ax(i),KEY,hlink); | 3 | 0 s | 0% |  |
All other lines | | | 0.011 s | 7.1% |  |
Totals | | | 0.153 s | 100% | |
Children (called functions)
Code Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 115 |
Non-code lines (comments, blank lines) | 58 |
Code lines (lines that can run) | 57 |
Code lines that did run | 24 |
Code lines that did not run | 33 |
Coverage (did run/can run) | 42.11 % |
Function listing
time calls line
1 function linkaxes(ax,option)
2 %LINKAXES Synchronize limits of specified 2-D axes
3 % Use LINKAXES to synchronize the individual axis limits
4 % on different subplots within a figure. Calling linkaxes
5 % will make all input axis have identical limits. This is useful
6 % when you want to zoom or pan in one subplot and display
7 % the same range of data in another subplot.
8 %
9 % LINKAXES(AX) Links x and y-axis limits of the 2-D axes
10 % specified in AX.
11 %
12 % LINKAXES(AX,OPTION) Links the axes AX according to the
13 % specified option. The option argument can be one of the
14 % following strings:
15 % 'x' ...link x-axis only
16 % 'y' ...link y-axis only
17 % 'xy' ...link x-axis and y-axis
18 % 'off' ...remove linking
19 %
20 % See the LINKPROP function for more advanced capabilities
21 % that allows linking object properties on any graphics object.
22 %
23 % Example (Linked Zoom & Pan):
24 %
25 % ax(1) = subplot(2,2,1);
26 % plot(rand(1,10)*10,'Parent',ax(1));
27 % ax(2) = subplot(2,2,2);
28 % plot(rand(1,10)*100,'Parent',ax(2));
29 % linkaxes(ax,'x');
30 % % Interactively zoom and pan to see link effect
31 %
32 % See also LINKPROP, ZOOM, PAN.
33
34 % Copyright 2003-2011 The MathWorks, Inc.
35
1 36 if nargin==0
37 fig = get(0,'CurrentFigure');
38 if isempty(fig), return; end
39 ax = findobj(gcf,'type','axes','-not','Tag','legend','-not','Tag','Colorbar');
40 nondatachild = logical([]);
41 for k=length(ax):-1:1
42 nondatachild(k) = isappdata(ax(k),'NonDataObject');
43 end
44 ax(nondatachild) = [];
45 option = 'xy';
46
1 47 else
1 48 if nargin==1
49 option = 'xy';
50 end
1 51 naxin = length(ax);
1 52 ax = findobj(ax(ishghandle(ax,'axes')),'flat','type','axes','-not','Tag',...
53 'legend','-not','Tag','Colorbar');
1 54 if ~isempty(ax) && length(ax)<naxin
55 warning('MATLAB:linkaxes:RequireDataAxes',...
56 'Excluding ColorBars, Legends and non-axes');
57 end
58
59 % Ensure that no axes are repeated.
1 60 [~,I] = unique(ax);
0.02 1 61 Idup = setdiff(1:length(ax),I);
1 62 ax(Idup) = [];
1 63 end
64
65
1 66 if isempty(ax)
67 error('MATLAB:linkaxes:InvalidFirstArgument', 'There must be at least one valid axes.');
68 end
1 69 h = handle(ax);
70
71 % Only support 2-D axes
1 72 if ~all(local_is2D(h))
73 warning('MATLAB:linkaxes:Requires2Dinput',...
74 'linkaxes requires 2-D axes as input. Use linkprop for generic property linking.');
75 end
76
77 % Remove any prior links to input handles
1 78 localRemoveLink(ax)
79
80 % Flush graphics queue so that all axes
81 % are forced to update their limits. Otherwise,
82 % calling XLimMode below may get the wrong axis limits
0.04 1 83 drawnow;
84
85 % Create new link
1 86 switch option
1 87 case 'x'
1 88 set(ax,'XLimMode','manual');
0.08 1 89 hlink = linkprop(ax,'XLim');
90 case 'y'
91 set(ax,'YLimMode','manual');
92 hlink = linkprop(ax,'YLim');
93 case 'xy'
94 set(ax,'XLimMode','manual','YLimMode','manual');
95 hlink = linkprop(ax,{'XLim','YLim'});
96 case 'off'
97 hlink = [];
98 otherwise
99 error('MATLAB:linkaxes:InvalidSecondArgument',...
100 'Second input argument must be one of ''x'', ''y'', ''xy'', or ''off''.');
101 end
102
1 103 KEY = 'graphics_linkaxes';
1 104 if ~feature('HGUsingMATLABClasses')
1 105 for i=1:length(ax)
3 106 setappdata(ax(i),KEY,hlink);
3 107 end
108 else
109 % MCOS graphics cannot rely on custom machinary in hgload to restore
110 % linkaxes. Instead, create a graphics.internal.LinkAxes to wrap the
111 % linkprop which will restore the linkaxes when it is de-serialized.
112 for i=1:length(ax)
113 setappdata(ax(i),KEY,graphics.internal.LinkAxes(hlink));
114 end
115 end
Other subfunctions in this file are not included in this listing.