0001 function h = SideAxes(a,location,s,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 gap = 0.1;
0037
0038
0039 if nargin < 2,
0040 error('Incorrect number of parameters (type ''help <a href="matlab:help SideAxes">SideAxes</a>'' for details).');
0041 end
0042
0043
0044 if nargin == 2,
0045 s = location;
0046 location = a;
0047 a = gca;
0048 elseif isastring(a),
0049 varargin = {s,varargin{:}};
0050 s = location;
0051 location = a;
0052 a = gca;
0053 end
0054
0055
0056 if mod(length(varargin),2) ~= 0,
0057 error('Incorrect number of parameters (type ''help <a href="matlab:help SideAxes">SideAxes</a>'' for details).');
0058 end
0059
0060
0061 if ~ishandle(a),
0062 error('Incorrect axes (type ''help <a href="matlab:help SideAxes">SideAxes</a>'' for details).');
0063 end
0064 if ~isdscalar(s,'>0','<1'),
0065 error('Incorrect size (type ''help <a href="matlab:help SideAxes">SideAxes</a>'' for details).');
0066 end
0067 location = lower(location);
0068 if ~isastring(location,'top','bottom','left','right'),
0069 error('Incorrect location (type ''help <a href="matlab:help SideAxes">SideAxes</a>'' for details).');
0070 end
0071
0072
0073 for i = 1:2:length(varargin),
0074 if ~ischar(varargin{i}),
0075 error(['Parameter ' num2str(i+2) ' is not a property (type ''help <a href="matlab:help SideAxes">SideAxes</a>'' for details).']);
0076 end
0077 switch(lower(varargin{i})),
0078 case 'gap',
0079 gap = varargin{i+1};
0080 if ~isdscalar(gap,'>=0','<1'),
0081 error('Incorrect value for property ''gap'' (type ''help <a href="matlab:help SideAxes">SideAxes</a>'' for details).');
0082 end
0083 otherwise,
0084 error(['Unknown property ''' num2str(varargin{i}) ''' (type ''help <a href="matlab:help SideAxes">SideAxes</a>'' for details).']);
0085 end
0086 end
0087
0088
0089
0090 main = a;
0091 position = get(main,'position');
0092 x = position(1);
0093 y = position(2);
0094 currentWidth = position(3);
0095 currentHeight = position(4);
0096
0097
0098 horizontalGap = currentWidth * gap;
0099 newWidth = currentWidth - horizontalGap;
0100 newMainWidth = newWidth * (1-s);
0101 newSideWidth = newWidth * s;
0102
0103
0104 verticalGap = currentHeight * gap;
0105 newHeight = currentHeight - verticalGap;
0106 newMainHeight = newHeight * (1-s);
0107 newSideHeight = newHeight * s;
0108
0109 xLims = get(main,'xlim');
0110 yLims = get(main,'ylim');
0111
0112 switch(location),
0113 case 'top',
0114 set(main,'position',[x y currentWidth newMainHeight]);
0115 h = axes('position',[x y+newMainHeight+verticalGap currentWidth newSideHeight]);
0116 xlim(h,xLims);
0117 case 'bottom',
0118 set(main,'position',[x y+newSideHeight+verticalGap currentWidth newMainHeight]);
0119 h = axes('position',[x y currentWidth newSideHeight]);
0120 xlim(h,xLims);
0121 case 'right',
0122 set(main,'position',[x y newMainWidth currentHeight]);
0123 h = axes('position',[x+newMainWidth+horizontalGap y newSideWidth currentHeight]);
0124 ylim(h,yLims);
0125 case 'left',
0126 set(main,'position',[x+newSideWidth+horizontalGap y newMainWidth currentHeight]);
0127 h = axes('position',[x y newSideWidth currentHeight]);
0128 ylim(h,yLims);
0129 end