%function ex_01_10()
close all;
%it plots boxplot
function boxplott(box,hax,r);
% box - the vector of the five-number description
% hax - the identifier (handle) of the graphic window
% r - indicates 'x' - coordinate of boxplot

  d=0.03;
  x=ones(1,5)*r;
%horizontal lines
P(1)=x(1)-d/2; P(2)=x(1)+d/2;
Q(1)=box(1);Q(2)=box(1);
line(hax,P(:),Q(:),"color","black");
P(1)=x(5)-d/2; P(2)=x(5)+d/2;
Q(1)=box(5);Q(2)=box(5);
line(hax,P(:),Q(:),"color","black");
for i=2:4
P(1)=x(i)-d; P(2)=x(i)+d;
Q(1)=box(i);Q(2)=box(i);
line(hax,P(:),Q(:),"color","black");
end
%vertical lines
P(1)=x(1); P(2)=x(5);
Q(1)=box(1);Q(2)=box(5);
line(hax,P(:),Q(:),"color","black");
%vertical lines
P(1)=x(1)-d; P(2)=x(5)-d;
Q(1)=box(2);Q(2)=box(4);
line(hax,P(:),Q(:),"color","black");
%vertical lines
P(1)=x(1)+d; P(2)=x(5)+d;
Q(1)=box(2);Q(2)=box(4);
line(hax,P(:),Q(:),"color","black");
end

%vectors of the five-number parameters for 3 data sets
%box=[the smallest value,quartile 1, median, quartile 2,the largest value];

box01=[46.34,46.73,47.12, 48.1975,50.26];
box02=[37.4,38.085,39.16,  41.58,  43.09];
box03=[34.57,35.565,36.11,36.8, 38.13];



figure();
axis ([0,1]);
hax=gca();
set(hax, "xtick", [0.3 0.6 0.9]);
hold on;
hax=gca();
r=0.3;
x=ones(1,5)*r;
plot(hax, x,box01,'.',"MarkerSize",12);
boxplott(box01,hax,r);

% fixing the size of coordinate axes
ylim([30,55]);
xlim([0,1]);

%the next plot doesn't erase next plot
hold on;

r=0.6;
x=ones(1,5)*r;
plot(hax,x,box02,'.',"MarkerSize",12);
boxplott(box02,hax,r);

r=0.9;
x=ones(1,5)*r;
plot(x,box03,'.',"MarkerSize",12);
boxplott(box03,hax,r);

set(hax, "xticklabel", {"birds1", "birds2", "birds3"});
title ("Hummingbirds - 3 kinds");

