axes(handles.profile);
cla;

i=handles.currentprofile;

col=['gbyrg'];


hold on;
axis ij;
grid on;
grey=[.5 .5 .5];
set(gca,'Xcolor',grey);
set(gca,'YColor',grey);
%axis([-2 35 -1000 0])
xlimit=[-2 35];
handles.menudepth=min(handles.menudepth,profiledata.depth(profiledata.ndep(1)));

%saveguidata

ymin=handles.menudepth-handles.profilefocus;
ymax=handles.menudepth+handles.profilefocus;
ylimit=[ymin ymax];
%ylimit=[0 1000];
set(handles.profile,'XLim',xlimit);
set(handles.profile,'YLim',ylimit);

plot(xlimit,[handles.menudepth handles.menudepth],'b-');
hold on

plot_clim;

isn=find(~isnan(profiledata.temp) & profiledata.temp<99.);

plot(profiledata.temp(isn),profiledata.depth(isn),'w-');
set(hg,'ButtonDownFcn','recenterprofileplotfcn');

%plot colored line of profile quality
clear xc
xc=zeros(size(profiledata.qc));
xc(length(xc)+1)=0.;
pd=profiledata.depth;
pd(length(pd)+1)=2000.;
for j=1:5
kk=find(profiledata.qc==num2str(j));

if(~isempty(kk))
    kk(length(kk)+1)=kk(length(kk))+1;
    xc2=xc*NaN;
    xc2(kk)=xc(kk);
%    if(kk(end)>length(profiledata.depth));kk(end)=[];end;
 hhp= plot(xc2,pd,'color',col(j));
 hold on
 set(hhp,'Linewidth',3.0);
end
end

% add quality flags at the correctdepth:
cs=0;
spot=-2;
for j=1:profiledata.numhists

    if(strmatch('CS',profiledata.QC_code(j,:)))
        if(~cs)
            cs=1;
            if(j>1 & profiledata.QC_depth(j)~= profiledata.QC_depth(j-1))
                spot=1;
            else
                spot=spot+3;
            end
   hht=text(spot,profiledata.QC_depth(j),profiledata.QC_code(j,:));
   set(hht,'Color','y');
        end
    else
            if(j>1 & profiledata.QC_depth(j)~= profiledata.QC_depth(j-1))
                spot=1;
            else
                spot=spot+3;
            end
   hht=text(spot,profiledata.QC_depth(j),profiledata.QC_code(j,:));
   set(hht,'Color','y');

    end
end
