function [figure1]=plot4sub(title1,xl1,yl1,X1, Y1,title2,xl2,yl2,  X2, Y2,title3, xl3,yl3, X3, Y3,title4,xl4,yl4, X4, Y4)
%makes a plot with a subplots

%CREATEFIGURE(X1,Y1,X2,Y2,Y3,Y4)
%  X1:  vector of x data
%  Y1:  vector of y data
%  X2:  vector of x data
%  Y2:  vector of y data
%  Y3:  vector of y data
%  Y4:  vector of y data

%  Auto-generated by MATLAB on 06-Mar-2012 08:55:41

% Create figure
figure1 = figure('Name',title1,'units','centimeters','Position',[0 0 40 15],...                    % setter str på figuren du vil se på skjermen. VIKIT Gat units kommer FØR Position
    'PaperUnits','centimeters','PaperPosition', [0 0 40 15],...% setter str på figuren du vil lagre (uavhengig av format) VIKITG at units kommer FØR Position
    'DefaultAxesFontSize',10,'DefaultAxesFontWeight','b');               %setter str på font i figure 


% Create axes
axes1 = axes('Parent',figure1,...
    'Position',[0.13 0.583837209302326 0.334659090909091 0.341162790697674]);
box(axes1,'on');
hold(axes1,'all');

% Create title
title(title1,'Interpreter','none');

% Create plot
plot(X1,Y1,'Parent',axes1,'linewidth',2,'color','k');
xlim([X1(1),X1(end)]);
xlabel(xl1);
ylabel(yl1);

% Create axes
axes2 = axes('Parent',figure1,...
    'Position',[0.570340909090909 0.583837209302326 0.334659090909091 0.341162790697674]);
% Uncomment the following line to preserve the X-limits of the axes
% xlim(axes2,[730486 734139]);
box(axes2,'on');
hold(axes2,'all');

% Create title
title(title2,'Interpreter','none');

% Create plot
plot(X2,Y2,'Parent',axes2,'linewidth',2,'color','k');

DV=datevec(X2);
if strcmp(title1(13:23),'RankinInlet')||  strcmp(title1(14:24),'RankinInlet')
    disp('')
else
set(gca,'xTick',X2(find(DV(:,2)==1 & DV(:,3)==1 )))
end
datetick('x','yymm','keepticks');
xlabel('Date[yymm]');
ylabel(yl2);
xlim([X2(1),X2(end)]);

% Create axes
axes3 = axes('Parent',figure1,...
    'Position',[0.13 0.11 0.334659090909091 0.341162790697674]);
box(axes3,'on');
hold(axes3,'all');

% Create title
title(title3,'Interpreter','none');

% Create plot
plot(X3,Y3,'Parent',axes3,'linewidth',2,'color','k');
xlim([X3(1),X3(end)]);
xlabel(xl3);
ylabel(yl3);


% Uncomment the following line to preserve the X-limits of the axes
% xlim(subplot1,[730486 734139]);
box(axes3,'on');
hold(axes3,'all');

axes4 = axes('Parent',figure1,...
    'Position',[0.570340909090909 0.11 0.334659090909091 0.341162790697674]);
box(axes4,'on');
hold(axes4,'all');

% Create title
title(title4,'Interpreter','none');

% Create plot
plot(X4,Y4,'Parent',axes4,'linewidth',2,'color','k');

DV=datevec(X4);
if strcmp(title1(13:23),'RankinInlet')||  strcmp(title1(14:24),'RankinInlet')
      disp('')
else
set(gca,'xTick',X4(find(DV(:,2)==1 & DV(:,3)==1 )))
end
datetick('x','yymm','keepticks');
xlabel('Date[yymm]');
ylabel(yl4);
xlim([X4(1),X4(end)]);
end


