function boxxd( X, Y, width, varargin )
% boxplot that can use plot2mif. Xu Di 2015 Feb 06

X = X-width/2; % to offset the boxplot away from the data points.
mm = nanmedian(Y); % median
q3 = quantile(Y, 0.75); % 3rd quantile
q1 = quantile(Y, 0.25); % 1st quantile
ww = (q3-q1)*1.5; % define the max length of whiskers
cc = max(size(Y(1,:))); % the number of columns in Y

wu = NaN(1, cc); % upper end of the upper whisker
wl = NaN(1, cc); % lower end of the lower whisker
for i = 1:cc
    Yi = Y(:, i);  
    wu(i) = max(Yi(Yi<q3(i)+ww(i)));
    wl(i) = min(Yi(Yi>q1(i)-ww(i)));
end

% horizontal lines
plot([X-width; X+width], [q1; q1], varargin{:});hold on
plot([X-width; X+width], [q3; q3], varargin{:});
plot([X-width; X+width], [mm; mm], varargin{:});
plot([X-width; X+width], [wu; wu], varargin{:});
plot([X-width; X+width], [wl; wl], varargin{:});

% vertical lines
plot([X-width; X-width], [q1; q3], varargin{:});
plot([X+width; X+width], [q1; q3], varargin{:});
plot([X; X], [q3; wu], varargin{:});
plot([X; X], [q1; wl], varargin{:});