figure(fignum);
clf

% MAGMATIC
subplot(1,5,1)
for i=1:length(dmi(:,1)),
    plot([0 dmi(i,[3 3]) 0],dmi(i,[1 1 2 2]),'r-');
    hold on
end
plot(Dmagm(:,2)+Dmagm(:,3)/2,Dmagm(:,1),'g-')
plot(Dmagm(:,2)-Dmagm(:,3)/2,Dmagm(:,1),'g-')
plot(Dmagm(:,2),Dmagm(:,1),'b-')
axis('ij'); axis([0 2 0 1420])
title('Magmatic - macroscopic'); ylabel('Depth, mbsf'); xlabel('Intensity')


% PLASTIC
subplot(1,5,4)
for i=1:length(dpi(:,1)),
    plot([0 dpi(i,[3 3]) 0],dpi(i,[1 1 2 2]),'r-');
    hold on
end
plot(Dplas(:,2)+Dplas(:,3)/2,Dplas(:,1),'g-')
plot(Dplas(:,2)-Dplas(:,3)/2,Dplas(:,1),'g-')
plot(Dplas(:,2),Dplas(:,1),'b-')
axis('ij'); axis([0 4 0 1420])
title('Plastic - macroscopic');xlabel('Intensity')

load U1309D_thinsect.dat
d=U1309D_thinsect;
i1=find(d(:,4)>-1 & d(:,4)<2);
i2=find(d(:,4)==2);
i3=find(d(:,4)==3);
nd=d(i1,:)

zb=0;ze=1400;dz=20;nz=zb+dz/2:dz:ze-dz/2;nz=nz';
v=zeros(length(nz),6);v=v./v;


for i=1:length(nz),
    ig=find(nd(:,1)>nz(i)-dz/2 & nd(:,1)<nz(i)+dz/2);
    if length(ig)>0,
        v(i,1:4)=[mean(nd(ig,2)) std(nd(ig,2)) mean(nd(ig,3)) std(nd(ig,3))];
    end
end
clear nd
nd=d([i2;i3],:);
for i=1:length(nz),
    ig=find(nd(:,1)>nz(i)-dz/2 & nd(:,1)<nz(i)+dz/2);
    if length(ig)>0,
        v(i,5:6)=[mean(nd(ig,3)) std(nd(ig,3))];
    end
end

    

%%%%%%%
subplot(1,5,2)
plot(d(i1,2),d(i1,1),'ro')
hold on
plot(v(:,1),nz,'k->')
axis('ij')
title('Magmatic - microscopic')
xlabel('Intensity')
axis([0 3.5 0 1420])

subplot(1,5,3)
plot(d(i1,3),d(i1,1),'ro')
hold on
plot(v(:,3),nz,'k->')
axis('ij')
title('Plastic - low stress microscopic')
xlabel('Intensity')
axis([0 5 0 1420])

subplot(1,5,5)
plot(d(i2,3),d(i2,1),'b*')
hold on
plot(d(i3,3),d(i3,1),'ro')
plot(v(:,5),nz,'k->')

axis('ij')
title('Plastic - high stress microscopic')
xlabel('Intensity')
axis([0 5 0 1420])