% This m-file semilogys the X-ray diffraction data of the MgB2 thin film 21Y
% used in the experiment conducted by PJC and WD using the mk-SHPM system
% on 09/03/2011.
%
% Thin film was grown and characterised by Jean-Baptiste Lalo\:{e}
%
% plot_XRDdata3a.m - Changes from plot_XRDdata3.m
% 1. Removed some PDF lines and shrunk the plot to make more room for AFM
% images
% 2. Changed linstyle of PDF markers to make Si lines more visible.
% plot_XRDdata3.m - Changes from plot_XRDdata2.m
% 1. Changed lines to dot/dashed and darker red/green.
%
% plot_XRDdata2.m - Changes from plot_XRDdata1.m
% 1. log y-axis
% 2. Adds RHS scale
%
%%% Load in data %%%
XRDdata=load('MgB2_Expt_XRDdata.txt');  %Experimental XRD of MGB2 thin film
SiPDF=load('XRD_Si_pdf.txt');           % 'Powder diffraction file' of Si
MgB2PDF=load('XRD_MgB2_pdf.txt');       % 'Powder diffraction file of MgB2
%
% Normalise Powder Diffraction File (PDF) data to largest peak from
% experimental data.
mxc=max(XRDdata(:,2));
SiPDF(:,2)=((SiPDF(:,2)/100)*mxc)/1000;
MgB2PDF(:,2)=((MgB2PDF(:,2)/100)*mxc)/1000;
%
%%% Start plotting %%%
figure
% Plot XRD experimental data
semilogy(XRDdata(:,1),XRDdata(:,2)/1000,'linewidth',2)
hold on
% Plot Si powder diffraction indices
semilogy([SiPDF(1,1) SiPDF(1,1)],[0.01 SiPDF(1,2)],'color',[0.6 0 0],'linestyle','--','linewidth',2);
plot([MgB2PDF(1,1) MgB2PDF(1,1)],[0.01 MgB2PDF(1,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2); % Just to sort legend out
text(SiPDF(1,1)-4,SiPDF(1,2)+3,['(' num2str(SiPDF(1,3)) ')'],'color',[0.6 0 0],'fontsize',24);
semilogy([SiPDF(2,1) SiPDF(2,1)],[0.01 SiPDF(2,2)],'color',[0.6 0 0],'linestyle','--','linewidth',2);
text(SiPDF(2,1)-3.25,SiPDF(2,2)+2,['(' num2str(SiPDF(2,3)) ')'],'color',[0.6 0 0],'fontsize',24);
semilogy([SiPDF(3,1) SiPDF(3,1)],[0.01 SiPDF(3,2)],'color',[0.6 0 0],'linestyle','--','linewidth',2);
text(SiPDF(3,1)-3.25,SiPDF(3,2)+1,['(' num2str(SiPDF(3,3)) ')'],'color',[0.6 0 0],'fontsize',24);
semilogy([SiPDF(4,1) SiPDF(4,1)],[0.01 SiPDF(4,2)],'color',[0.6 0 0],'linestyle','--','linewidth',2);
text(SiPDF(4,1)-3.25,SiPDF(4,2)+0.2,['(' num2str(SiPDF(4,3)) ')'],'color',[0.6 0 0],'fontsize',24);
semilogy([SiPDF(5,1) SiPDF(5,1)],[0.01 SiPDF(5,2)],'color',[0.6 0 0],'linestyle','--','linewidth',2);
text(SiPDF(5,1)-3.25,SiPDF(5,2)+0.5,['(' num2str(SiPDF(5,3)) ')'],'color',[0.6 0 0],'fontsize',24);
semilogy([SiPDF(6,1) SiPDF(6,1)],[0.01 SiPDF(6,2)],'color',[0.6 0 0],'linestyle','--','linewidth',2);
text(SiPDF(6,1)-3.25,SiPDF(6,2)+0.5,['(' num2str(SiPDF(6,3)) ')'],'color',[0.6 0 0],'fontsize',24);
semilogy([SiPDF(7,1) SiPDF(7,1)],[0.01 SiPDF(7,2)],'color',[0.6 0 0],'linestyle','--','linewidth',2);
text(SiPDF(7,1)-3.25,SiPDF(7,2)+6,['(' num2str(SiPDF(7,3)) ')'],'color',[0.6 0 0],'fontsize',24);
%
plot([MgB2PDF(1,1) MgB2PDF(1,1)],[0.01 MgB2PDF(1,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2);
text(MgB2PDF(1,1)-3.75,MgB2PDF(1,2)+0.5,'(001)','color',[0 0.6 0],'fontsize',24);
plot([MgB2PDF(2,1) MgB2PDF(2,1)],[0.01 MgB2PDF(2,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2);
text(MgB2PDF(2,1)-3.25,MgB2PDF(2,2)+1.5,['(' num2str(MgB2PDF(2,3)) ')'],'color',[0 0.6 0],'fontsize',24);
plot([MgB2PDF(3,1) MgB2PDF(3,1)],[0.01 MgB2PDF(3,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2);
text(MgB2PDF(3,1)-3.25,MgB2PDF(3,2)+1.5,['(' num2str(MgB2PDF(3,3)) ')'],'color',[0 0.6 0],'fontsize',24);
plot([MgB2PDF(4,1) MgB2PDF(4,1)],[0.01 MgB2PDF(4,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2);
text(MgB2PDF(4,1)-3.25,MgB2PDF(4,2)+0.2,'(002)','color',[0 0.6 0],'fontsize',24);
%plot([MgB2PDF(5,1) MgB2PDF(5,1)],[0.01 MgB2PDF(5,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2);
%text(MgB2PDF(5,1)-3.25,MgB2PDF(5,2)+0.5,'(210)','color',[0 0.6 0],'fontsize',24);
%plot([MgB2PDF(6,1) MgB2PDF(6,1)],[0.01 MgB2PDF(6,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2);
%text(MgB2PDF(6,1)-3.25,MgB2PDF(6,2)+0.5,['(' num2str(MgB2PDF(6,3)) ')'],'color',[0 0.6 0],'fontsize',24);
%plot([MgB2PDF(7,1) MgB2PDF(7,1)],[0.01 MgB2PDF(7,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2);
%text(MgB2PDF(7,1)-3.25,MgB2PDF(7,2)+0.5,'(211)','color',[0 0.6 0],'fontsize',24);
%plot([MgB2PDF(8,1) MgB2PDF(8,1)],[0.01 MgB2PDF(8,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2);
%text(MgB2PDF(8,1)-3.5,MgB2PDF(8,2)+1.5,['(' num2str(MgB2PDF(8,3)) ')'],'color',[0 0.6 0],'fontsize',24);
plot([MgB2PDF(9,1) MgB2PDF(9,1)],[0.01 MgB2PDF(9,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2);
text(MgB2PDF(9,1)-3.25,MgB2PDF(9,2)+1,['(' num2str(MgB2PDF(9,3)) ')'],'color',[0 0.6 0],'fontsize',24);
plot([MgB2PDF(10,1) MgB2PDF(10,1)],[0.01 MgB2PDF(10,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2);
text(MgB2PDF(10,1)-3.25,MgB2PDF(10,2)+1,'(003)','color',[0 0.6 0],'fontsize',24);
plot([MgB2PDF(11,1) MgB2PDF(11,1)],[0.01 MgB2PDF(11,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2);
text(MgB2PDF(11,1)-3,MgB2PDF(11,2)+0.2,'(212)','color',[0 0.6 0],'fontsize',15);
plot([MgB2PDF(12,1) MgB2PDF(12,1)],[0.01 MgB2PDF(12,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2);
text(MgB2PDF(12,1)-1.25,MgB2PDF(12,2)+0.1,['(' num2str(MgB2PDF(12,3)) ')'],'color',[0 0.6 0],'fontsize',10);
plot([MgB2PDF(13,1) MgB2PDF(13,1)],[0.01 MgB2PDF(13,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2);
text(MgB2PDF(13,1)-3.25,MgB2PDF(13,2)+0.2,['(' num2str(MgB2PDF(13,3)) ')'],'color',[0 0.6 0],'fontsize',24);
plot([MgB2PDF(14,1) MgB2PDF(14,1)],[0.01 MgB2PDF(14,2)],'color',[0 0.6 0],'linestyle','-','linewidth',2);
text(MgB2PDF(14,1)-3.25,MgB2PDF(14,2)+0.5,'(310)','color',[0 0.6 0],'fontsize',24);
%
set(gca,'FontSize',30)
xlabel('Diffraction angle (\circ)','fontsize',35)
ylabel('Intensity (Counts x10^{3})','fontsize',35)
axis([0 110 0.01 100])
legend('MgB_2 thin film','Poly-crystalline Si','Poly-crystalline MgB_2')
%
text(111,100,['10^3'],'fontsize',24);shg
text(111,10,['10^2'],'fontsize',24);shg
text(111,1,['10^1'],'fontsize',24);shg
text(111,0.1,['10^0'],'fontsize',24);shg
text(111,0.011,['10^{-1}'],'fontsize',24);shg
text(117,0.025,['Relative diffraction intensity (%)'],'rotation',90,'fontsize',35);shg