clc, clear, close all % Supplementary Figure showing the effect of population size % generate data by running 'run_nonregulatory.m' with settings % for all sub-figures: % Nloci= 1; % tmax = 2000; % mutation_rate = 0.0001; % broodsize = 10; % benefit = [2 4 10]; % replicates= 10; % initial_conditions = 0; % type_gene = 1; % for specific sub-figures: % matings= 10; for data_SF3A.mat % matings= 100; for data_SF3B.mat % matings= 1000; for data_SF3C.mat % matings= 10000; for data_SF3D.mat gap=0.02; marg_h=0.11; marg_w=0.1; mylinewidth=2; subplot = @(m,n,p) subtightplot(m,n,p,gap,marg_h,marg_w); fontsize1=16; fontsize2=14; fontsize3=20; axislinewidth=1; linewidth1=2; linewidth2=1; set(0,'DefaultAxesTitleFontWeight','normal'); set(figure(1), 'Position', [420 600 500 400]) figure(1) %set(groot,'defaultAxesColorOrder',[0.5 0.5 0.5]) load data_SF3A.mat r=0.5; % we assume full-sib interactions p_analytic=(r.*benefit - 1)./(benefit - 1); p_analytic=repmat(p_analytic', [1 tmax 1]); subplot(2,2,1) for j=1:length(benefit) plot(1:tmax,mean(p(1:i,:,j),1),'LineWidth',linewidth1) hold on end plot(1:tmax,p_analytic(1,:),'--k',1:tmax,p_analytic(2,:),'--k',1:tmax,p_analytic(3,:),'--k','LineWidth',linewidth2) xlim([0 tmax]) ylim([-0.1 1]) xlabel('generations') set(gca,'XTick','') %title('allele type: discrete') text(50,0.9,'a)','FontSize', fontsize3); ax = gca; ax.LineWidth = axislinewidth; ax.FontSize = fontsize2; h = text(-420,-0.9,'propensity for altruism ({\itp})','fontsize', fontsize3); set(h, 'rotation', 90) load data_SF3B.mat subplot(2,2,2) for j=1:length(benefit) plot(1:tmax,mean(p(1:i,:,j),1),'LineWidth',linewidth1) hold on end plot(1:tmax,p_analytic(1,:),'--k',1:tmax,p_analytic(2,:),'--k',1:tmax,p_analytic(3,:),'--k','LineWidth',linewidth2) xlim([0 tmax]) ylim([-0.1 1]) % xlabel('generations') % ylabel('Propensity of altruism (p)') set(gca,'XTick','') set(gca,'YTick','') if length(benefit)==1 legend({['benefit= ',num2str(benefit(1))]},'FontSize',10,'Location','NorthEast') elseif length(benefit)==2 legend({['benefit= ',num2str(benefit(1))],num2str(benefit(2))},'FontSize',10,'Location','NorthEast') elseif length(benefit)==3 legend({['{\it b} = ',num2str(benefit(1))],['{\it b} = ',num2str(benefit(2))],['{\it b} = ',num2str(benefit(3))]},'FontSize',10,'Location','NorthEast') end legend('boxoff') %title('allele type: quantitative') text(50,0.9,'b)','FontSize', fontsize3); ax = gca; ax.LineWidth = axislinewidth; ax.FontSize = fontsize2; %h = text(2190,0.9,'primary loci = 1','fontsize', fontsize1); set(h, 'rotation', 270) load data_SF3C.mat subplot(2,2,3) for j=1:length(benefit) plot(1:tmax,mean(p(1:i,:,j),1),'LineWidth',linewidth1) hold on end plot(1:tmax,p_analytic(1,:),'--k',1:tmax,p_analytic(2,:),'--k',1:tmax,p_analytic(3,:),'--k','LineWidth',linewidth2) xlim([0 tmax]) ylim([-0.1 1]) set(gca,'XTick',[0 500 1000 1500]) h = text(1600,-0.33,'generations','fontsize', fontsize3); text(50,0.9,'c)','FontSize', fontsize3); ax = gca; ax.LineWidth = axislinewidth; ax.FontSize = fontsize2; load data_SF3D.mat subplot(2,2,4) for j=1:length(benefit) plot(1:tmax,mean(p(1:i,:,j),1),'LineWidth',linewidth1) hold on end plot(1:tmax,p_analytic(1,:),'--k',1:tmax,p_analytic(2,:),'--k',1:tmax,p_analytic(3,:),'--k','LineWidth',linewidth2) xlim([0 tmax]) ylim([-0.1 1]) %ylabel('Propensity of altruism (p)') set(gca,'YTick','') text(50,0.9,'d)','FontSize', fontsize3); ax = gca; ax.LineWidth = axislinewidth; ax.FontSize = fontsize2; %h = text(2190,0.9,'primary loci = 50','fontsize', fontsize1); set(h, 'rotation', 270) rez=400; %resolution (dpi) of final graphic f=gcf; %f is the handle of the figure you want to export figpos=getpixelposition(f); %dont need to change anything here resolution=get(0,'ScreenPixelsPerInch'); %dont need to change anything here set(f,'paperunits','inches','papersize',figpos(3:4)/resolution,'paperposition',[0 0 figpos(3:4)/resolution]); %dont need to change anything here path=pwd; % save file in current folder name='figure1.jpeg'; %what you want the file to be called print(f,fullfile(path,name),'-djpeg',['-r',num2str(rez)],'-opengl') %save file