function mysubplot(nrow,ncol,jrc,width,height,axsp,betw,iibar,dxdy_eq)
%
% Call mysubplot(nrow,ncol,jrc,width,height,axsp,betw,iibar)
% nrow,ncol	= number of rows and columns of subplots;
% jrc		= number of current plot, counted along rows first;
% width,height = total width, height of figure;
% axsp		= inches allowed for axes on left and bottom (0.6 recommended);
% betw		= inches between plot axes;
% iibar		= 1 to plot colorbar to right of rightmost plots;
% dxdy_eq	= [delx dely] of plots that you want to have equal axes of.
%
% Example call:
% width=6.4; height=7.333;
% axsp=0.6; betw=0.1;
% for j=1:8,
% 	mysubplot(4,2,j,width,height,axsp,betw);
% Generate image in axes here (without calling new figure):
% 	[r_mat,th_mat,tl_mat,zsrc,zrec]=ray_rtheta_new_a3d(rth_root,zs(j),100, ...
% 		0,2,0,10,-200,-thmax,thmax,[],1,0,dbdyn,0,jet,0,0);
% Write text:
% 	text(rmax,-thmax,['zs = ',int2str(zs(j)),' '],'Fontname','Times', ...
% 		'Fontsize',12,'HorizontalAlignment','Right', ...
% 		'VerticalAlignment','Bottom')
% This call deletes labels:
% 	mysubplot(4,2,j)
% end
%
global horlen verlen ms_nplot ms_width ms_height ms_axsp ms_betw  ...
	ms_iibar ms_ax ms_brat ms_man
if nargin<9, dxdy_eq=[]; end
%
%
jrow=floor((jrc-1)/ncol) + 1;
jcol=mod(jrc-1,ncol) + 1;
%
if nargin>3,
	if width==0, width=5; end
	if height==0, height=4; end
	if nargin<6, axsp=1; end; if isempty(axsp), axsp=1; end
	if nargin<7, betw=0.125; end; if isempty(betw), betw=0.125; end
	if nargin<8, iibar=0; end;
	if jrc==1,
		figure
		set(gcf,'units','in');
		set(gcf,'pos',[.25,.25,width+1+axsp,height+1+axsp]);
%		horlen=(width-axsp-(ncol-1)*betw)/ncol;
%		verlen=(height-axsp-(nrow-1)*betw)/nrow;
		horlen=(width-(ncol-1)*betw)/ncol;
		verlen=(height-(nrow-1)*betw)/nrow;
		if ~isempty(dxdy_eq),
			outsize=ax_eq_size([horlen verlen],dxdy_eq(1),dxdy_eq(2));
			horlen=outsize(1); verlen=outsize(2);
		end
		ms_width=width; ms_height=height; ms_axsp=axsp; ms_betw=betw; ms_iibar=iibar;
		ms_nplot=nrow*ncol;
	end
%
	hstart=axsp + (jcol-1)*(horlen+betw);
	vstart=axsp + height - (jrow*(verlen+betw));
	pos=[hstart,vstart,horlen,verlen];
	
	ms_ax=axes('Units','in','Position',pos);
else
	if jcol~=1, ylabel(''); set(gca,'yticklabel',''); end
	if jrow~=nrow; xlabel(''); set(gca,'xticklabel',''); end
	title('');
end
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
