Home > atmlab > graphs > axes_mxn.m

axes_mxn

PURPOSE ^

------------------------------------------------------------------------

SYNOPSIS ^

function axes_mxn(m,n,s,b,l,t,r,label)

DESCRIPTION ^

------------------------------------------------------------------------
 NAME:    axes_mxn(m,n,s)

          Sets tight axes for figures with a nxm matrix of subplots.

          This function is useful when the horisontal grid of the subplots
          is identical.

 RETURN:  -
 IN:      m       the number of rows of sub-plots
          n       the number of columns of subplots
          s       space between plots  (optional)
          b       space at the bottom (optional)
          l       space at the left (optional)
          t       space at the top (optional)
          r       space at the right (optional) 
          label   remove ticklabels (optional)
           'on'

 EXAMPLE: axes_mxn(3,3,0.02,0.13,0.13,0.13,0.13)  
------------------------------------------------------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

axes_mxn.m

SOURCE CODE ^

0001 %------------------------------------------------------------------------
0002 % NAME:    axes_mxn(m,n,s)
0003 %
0004 %          Sets tight axes for figures with a nxm matrix of subplots.
0005 %
0006 %          This function is useful when the horisontal grid of the subplots
0007 %          is identical.
0008 %
0009 % RETURN:  -
0010 % IN:      m       the number of rows of sub-plots
0011 %          n       the number of columns of subplots
0012 %          s       space between plots  (optional)
0013 %          b       space at the bottom (optional)
0014 %          l       space at the left (optional)
0015 %          t       space at the top (optional)
0016 %          r       space at the right (optional)
0017 %          label   remove ticklabels (optional)
0018 %           'on'
0019 %
0020 % EXAMPLE: axes_mxn(3,3,0.02,0.13,0.13,0.13,0.13)
0021 %------------------------------------------------------------------------
0022 
0023 % HISTORY: 2004-03-30  Created by Samuel Brohede brohede@rss.chalmers.se
0024 
0025 function axes_mxn(m,n,s,b,l,t,r,label)
0026 
0027 if ~exist('s');s=0.03;end    
0028 if ~exist('b');b=0.13;end    
0029 if ~exist('l');l=0.13;end   
0030 if ~exist('t');t=0;end   
0031 if ~exist('r');r=0;end     
0032 if (~exist('label','var') | isempty(label))
0033     label = 'on';
0034 end
0035 
0036 if n==1 & m==1, return,end
0037 
0038 x0=l;
0039 y0=b;
0040 
0041 yh=((1-(m)*s)-y0-t)/m;
0042 xw=((1-(n)*s)-x0-r)/n;
0043 
0044 k=1;
0045 for i=1:m
0046     for j=1:n
0047         subplot(m,n,k)
0048         set(gca,'Pos',[x0+(j-1)*s+(j-1)*xw y0+(m-i)*s+(m-i)*yh xw yh]);
0049         k=k+1;
0050         if ~(j==1) & strcmp(label,'on');
0051            set(gca,'YTickLabel','');
0052         end   
0053         if ~(i==m) & strcmp(label,'on');
0054             set(gca,'XTickLabel','');
0055         end
0056     end
0057 end
0058

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005