clear all
% model written by Allison Shaw (contact for assistance: ashaw@umn.edu)
%   last updated: 10 June 2022

beta = 2;  % transmission rate (density-dependent) [per ind per year]
h1 = 0.05; % half-saturation constant for type II transmission
h2 = 0.1;  % half-saturation constant for type II transmission
h3 = 1;    % half-saturation constant for type II transmission

Uvec = linspace(0,5,100);

DD = beta*Uvec;
FD = beta*Uvec./(Uvec);
t1 = beta*Uvec./(h1+Uvec);
t2 = beta*Uvec./(h2+Uvec);
t3 = beta*Uvec./(h3+Uvec);

width = 5.5;
height = 5.5;
xpos = 3;
ypos = 2;
sx = 0.12;
sy = 0.17;
w = 0.8;
he = 0.8;

fs1 = 10;  % axes labels
fs3 = 09;  % axis numbering
lw2 = 1; % fig edges
lw1 = 1.5; % lines

c2 = [0.0512    0.4600    0.8633];	%dark blue
c3 = [0.4669    0.7487    0.4925];	%green
c4 = [0.9224    0.7256    0.3018];	%dark orange

figure(1); clf
hh = gcf;
set(hh,'PaperUnits','centimeters');
set(hh,'Units','centimeters');
set(gcf,'Position',[xpos ypos width height])

axes('position',[sx sy w he])
plot(Uvec,FD,'k','LineWidth',lw1)
hold on
plot(Uvec,t1,'color',c2,'LineWidth',lw1)
plot(Uvec,t2,'color',c3,'LineWidth',lw1)
plot(Uvec,t3,'color',c4,'LineWidth',lw1)
plot(Uvec,DD,'k--','LineWidth',lw1)
legend('FD (h = 0)','h = 0.05','h = 0.1','h = 1','DD','location','southeast','AutoUpdate','off')
hold on
axis([0 5 0 2.3])
xlabel('host density','fontsize',fs1)
set(gca,'FontSize',fs3,'LineWidth',lw2,'Fontname', 'Arial');
set(gca,'YTick',[0 beta])
set(gca,'YTickLabel',{'0','\beta'})


% Backup previous settings
prePaperType = get(hh,'PaperType');
prePaperPosition = get(hh,'PaperPosition');
prePaperSize = get(hh,'PaperSize');

% Make changing paper type possible
set(hh,'PaperType','<custom>');
% Set the page size and position to match the figure's dimensions
position = get(hh,'Position');
set(hh,'PaperPosition',[0,0,position(3:4)]);
set(hh,'PaperSize',position(3:4));

%saveas(1,strcat(['fig3.jpg']))
%print -dpdf -r600 Figure_3.pdf
print -djpeg -r600 fig1b.jpg

% Restore the previous settings
set(hh,'PaperType',prePaperType);
set(hh,'PaperPosition',prePaperPosition);
set(hh,'PaperSize',prePaperSize);
