function y=dtplot(timeu,yy,mid,type);
% y=dtplot(time,yy,mid,type)
% time=time vector
% yy = year
% mid = mooring id number
% type= data time type
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Function routine to try and get around an
% annoying bug in the batch processing of
% plots from a scripts.  The xaxis keeps
% changing from plot to plot.  Try to 
% isolate things in this file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%# Add flag as last parameter for plotting.
%# Need a bounds for the plotting.
%# Only plot no data if we really have no data.
%#
fpath=['/data/span9/bahr/perlprogs/'];
yylim=[0 70];
maxylim=yylim(2);
minylim=yylim(1);
switch(type)
	case 1,
		fend=['met'];
	case 2,
		fend=['ctd'];
	case 3,
		fend=['tstring'];
	case 4,
		fend=['gps'];
	otherwise,
		fend=['fend'];
end
% load the time limit file
eval([' load ',fpath,'time.dat;']);
eval([' gtime=time;']);
end_time=datenum(gtime(1),gtime(2),gtime(3),gtime(4),gtime(5),0);
ylab=['Time difference (min)'];
	cla reset;
	figure('Visible','off','Position',[200 200 600 270]);
	set(gcf,'Units','inches');
	set(gcf,'PaperPosition',[1.5 1.5 8 6]);
%# We want all times.
	xtc=ydtostr(yy,timeu);
	xmi=min(xtc);
	xma=end_time;
	dxt=xma-xmi;
% Add code to plot gaps as gaps
	if isempty(xtc)==0,
	lx=size(xtc,1);
	x1=xtc(1:lx-1,1);
	x2=xtc(2:lx,1);
	zc=(x1+x2)./2;
	iz=(x2-x1).*24*60;
	xtc=zc;
	tvar=iz;
	set(gca,'XLimMode','manual');
	plot(xtc,tvar,'b');
	if dxt < 7.0,
		xmi=xma-7;
	end
	tiz=[floor(xmi):ceil(xma)];
	set(gca,'XTick',tiz);	
	hold on;
	datetick('x',6);
	set(gca,'XLim',[xmi xma]);
	set(gca,'Ylim',[minylim maxylim]);
	grid on;
	xlabel(['Date (',num2str(yy),')'],'FontWeight','bold','FontSize',20);
	ylabel(ylab,'FontWeight','bold','FontSize',20);
	set(gca,'FontWeight','bold','FontSize',20);
	set(gca,'Box','on');
	pltnm=[fpath,'m',num2str(mid),'_dt',fend,'.ppm'];
	eval(['print -dppm ',pltnm,';']);
	clf;
	close all;
end
