function subplot_(x_center,y_center,width_,height_,visible_);
%function subplot_(x_center,y_center,width_,height_,visible_);
%
% Defines an axis wherever specified within a figure frame
%
% Input:
%	x_center	x-coordinate of center of subplot box (from 0 to 1)
%	y_center	y-coordinate of center of subplot box (from 0 to 1)
%	width_		Percentage of figure width spanned by subplot box
%	height_		Percentage of figure height spanned by subplot box
%	visible_	If set to 'y', the axis is kept visible (DEFAULT - off)
%
% Possible to enable so that incompatible inputs (box too big given center
% location) results in shrinking of the box to make it fit with the given
% center location.
%

% Size deflation factor
% Used to avoid pushing edge of windows, and losing peripheral information
%z=0.9;
% Not (yet?) incorporated

% Must input all four numbers
if nargin<4; error('Error - Not enough input parameters specified'), end;

% Some flexability in inputs
if x_center>1 & x_center<=100; x_center=x_center/100; end;
if y_center>1 & y_center<=100; y_center=y_center/100; end;
if width_>1 & width_<=100; width_=width_/100; end;
if height_>1 & height_<=100; height_=height_/100; end;

% Error if (adjusted) values not between 0 and 1
if x_center<0 | x_center>1 | y_center<0 | y_center>1 | width_<0 | width_>1 | height_<0 | height_>1; error('Error - Improper input parameters specified'), end;

% Set lower left corner, which "axes" statement uses
x_=x_center-0.5*width_; y_=y_center-0.5*height_;

% If width or height do not work give center location, shrink the box
%if x_<0; x_=0; width_=x_center*2; end;
%if y_<0; y_=0; height_=y_center*2; end;
%if x_center+0.5*width_>1; width_=(1-x_center)*2; x_=x_center-0.5*width_; end;
%if y_center+0.5*height_>1; height_=(1-y_center)*2; y_=y_center-0.5*height_; end;

size_=[width_ height_];
axes('position',[x_ y_ size_]); set(gca,'visible','off');

if nargin>=5; if visible_(1)=='y'; set(gca,'visible','on'); end; end;

%[x_center y_center size_ x_ y_]
