close all; clear; % boxplots for context effect index load('all_ce.mat') aw_=all_ce(:,1)==1; n_aw=sum(aw_); an_=all_ce(:,1)==2; n_an=sum(an_); chi_=all_ce(:,1)==3; n_chi=sum(chi_); nav=all_ce(:,2:3); com=all_ce(:,4:5); % comparisons y1=nan(117,4); y2=nan(117,4); y1(1:n_aw,1:2)=nav(aw_,:); y1(1:n_an,3:4)=nav(an_,:); y2(1:n_aw,1:2)=com(aw_,:); y2(1:n_an,3:4)=com(an_,:); y3=[(y1(:,2)-y1(:,1))./2,(y2(:,2)-y2(:,1))./2,(y1(:,4)-y1(:,3))./2,(y2(:,4)-y2(:,3))./2] ; %% plotting red =[0.8500,0.3250, 0.0980]; blue=[0,0.4470,0.7410]; red_light=[1,0.5,0.5].*red; blue_light=[1,0.5,0.5].*blue; colors=[blue;blue_light;red;red_light]; wid=160; hei=180; x = 1:4; figure(1); set(gcf,'Position',[400 200 wid hei]) ax = axes(); hold(ax); for i=1:4 h=boxchart(x(i)*ones(size(y1(:,i))), y1(:,i), 'BoxFaceColor', colors(i,:),'Notch','on'); h.MarkerStyle='.'; h.MarkerColor=colors(i,:); end hold on plot(1:2,nanmedian(y1(:,1:2)),'-o','LineWidth',1,'Color',blue,'MarkerSize',3,'MarkerFaceColor',blue) plot(3:4,nanmedian(y1(:,3:4)),'-o','LineWidth',1,'Color',red,'MarkerSize',3,'MarkerFaceColor',red) hold off xlim([0.5 4.5]) ylabel('echolocation effect') xticklabels({'match','mismatch','match','mismatch'}); set(gca, 'box', 'off') set(gca, 'Color','none') set(gca,'linewidth',1);set(gca,'fontsize',8); %% add stats pv1=signrank(y1(:,1),y1(:,2)); pv2=signrank(y1(:,3),y1(:,4)); pv3=ranksum(y1(:,1),y1(:,3)); pv4=ranksum(y1(:,2),y1(:,4)); xt = get(gca, 'XTick'); line1=0.45; line2=0.65; line3=0.85; sl=0.75; % plot lines for comparison hold on plot(xt(1:2), [1 1]*line1, '-k','LineWidth',sl) plot([1;1]*xt(1),[line1,line1-0.05],'-k', 'LineWidth',sl); plot([1;1]*xt(2),[line1,line1-0.05],'-k', 'LineWidth',sl); plot(xt(3:4), [1 1]*line1, '-k','LineWidth',sl) plot([1;1]*xt(3),[line1,line1-0.05],'-k', 'LineWidth',sl); plot([1;1]*xt(4),[line1,line1-0.05],'-k', 'LineWidth',sl); plot([xt(1) xt(3)], [1 1]*line2, '-k','LineWidth',sl) plot([1;1]*xt(1),[line2,line2-0.05],'-k', 'LineWidth',sl); plot([1;1]*xt(3),[line2,line2-0.05],'-k', 'LineWidth',sl); plot([xt(2) xt(4)], [1 1]*line3, '-k','LineWidth',sl) plot([1;1]*xt(2),[line3,line3-0.05],'-k', 'LineWidth',sl); plot([1;1]*xt(4),[line3,line3-0.05],'-k', 'LineWidth',sl); ylim([-1 1]) % plot level of significance if pv1 <= 0.05 && pv1 > 0.01 text(mean(xt(1:2))-0.025, line1+0.05, '*') elseif pv1 <=0.01 && pv1 > 0.001 text(mean(xt(1:2))-0.05, line1+0.05, '**') elseif pv1 <= 0.001 text(mean(xt(1:2))-0.15, line1+0.05, '***') else text(mean(xt(1:2))-0.05, line1+0.1, 'ns','FontSize',8) end if pv2 <= 0.05 && pv2 > 0.01 text(mean(xt(3:4))-0.025, line1+0.05, '*') elseif pv2 <=0.01 && pv2 > 0.001 text(mean(xt(3:4))-0.05, line1+0.05, '**') elseif pv2 <= 0.001 text(mean(xt(3:4))-0.15, line1+0.05, '***') else text(mean(xt(3:4))-0.05, line1+0.1, 'ns','FontSize',8) end if pv3 <= 0.05 && pv3 > 0.01 text(mean(xt(1:3))-0.025, line2+0.05, '*') elseif pv3 <=0.01 && pv3 > 0.001 text(mean(xt(1:3))-0.05, line2+0.05, '**') elseif pv3 <= 0.001 text(mean(xt(1:3))-0.15, line2+0.05, '***') else text(mean(xt(1:3))-0.05, line2+0.1, 'ns','FontSize',8) end if pv4 <= 0.05 && pv4 > 0.01 text(mean(xt(2:4))-0.025, line3+0.05, '*') elseif pv4 <=0.01 && pv4 > 0.001 text(mean(xt(2:4))-0.05, line3+0.05, '**') elseif pv4 <= 0.001 text(mean(xt(2:4))-0.15, line3+0.05, '***') else text(mean(xt(2:4))-0.05, line3+0.1, 'ns','FontSize',8) end %% plotting number 2 figure(2); set(gcf,'Position',[400 200 wid hei]) ax = axes(); hold(ax); for i=1:4 h=boxchart(x(i)*ones(size(y2(:,i))), y2(:,i), 'BoxFaceColor', colors(i,:),'Notch','on'); h.MarkerStyle='.'; h.MarkerColor=colors(i,:); end hold on plot(1:2,nanmedian(y2(:,1:2)),'-o','LineWidth',1,'Color',blue,'MarkerSize',3,'MarkerFaceColor',blue) plot(3:4,nanmedian(y2(:,3:4)),'-o','LineWidth',1,'Color',red,'MarkerSize',3,'MarkerFaceColor',red) hold off xlim([0.5 4.5]) ylabel('communication effect') xticklabels({'match','mismatch','match','mismatch'}); set(gca, 'box', 'off') set(gca, 'Color','none') set(gca,'linewidth',1);set(gca,'fontsize',8); %% add stats pv1=signrank(y2(:,1),y2(:,2)); pv2=signrank(y2(:,3),y2(:,4)); pv3=ranksum(y2(:,1),y2(:,3)); pv4=ranksum(y2(:,2),y2(:,4)); xt = get(gca, 'XTick'); % plot lines for comparison hold on plot(xt(1:2), [1 1]*line1, '-k','LineWidth',sl) plot([1;1]*xt(1),[line1,line1-0.05],'-k', 'LineWidth',sl); plot([1;1]*xt(2),[line1,line1-0.05],'-k', 'LineWidth',sl); plot(xt(3:4), [1 1]*line1, '-k','LineWidth',sl) plot([1;1]*xt(3),[line1,line1-0.05],'-k', 'LineWidth',sl); plot([1;1]*xt(4),[line1,line1-0.05],'-k', 'LineWidth',sl); plot([xt(1) xt(3)], [1 1]*line2, '-k','LineWidth',sl) plot([1;1]*xt(1),[line2,line2-0.05],'-k', 'LineWidth',sl); plot([1;1]*xt(3),[line2,line2-0.05],'-k', 'LineWidth',sl); plot([xt(2) xt(4)], [1 1]*line3, '-k','LineWidth',sl) plot([1;1]*xt(2),[line3,line3-0.05],'-k', 'LineWidth',sl); plot([1;1]*xt(4),[line3,line3-0.05],'-k', 'LineWidth',sl); ylim([-1 1]) % plot level of significance if pv1 <= 0.05 && pv1 > 0.01 text(mean(xt(1:2))-0.025, line1+0.05, '*') elseif pv1 <=0.01 && pv1 > 0.001 text(mean(xt(1:2))-0.05, line1+0.05, '**') elseif pv1 <= 0.001 text(mean(xt(1:2))-0.15, line1+0.05, '***') else text(mean(xt(1:2))-0.05, line1+0.1, 'ns','FontSize',8) end if pv2 <= 0.05 && pv2 > 0.01 text(mean(xt(3:4))-0.025, line1+0.05, '*') elseif pv2 <=0.01 && pv2 > 0.001 text(mean(xt(3:4))-0.05, line1+0.05, '**') elseif pv2 <= 0.001 text(mean(xt(3:4))-0.15, line1+0.05, '***') else text(mean(xt(3:4))-0.05, line1+0.1, 'ns','FontSize',8) end if pv3 <= 0.05 && pv3 > 0.01 text(mean(xt(1:3))-0.025, line2+0.05, '*') elseif pv3 <=0.01 && pv3 > 0.001 text(mean(xt(1:3))-0.05, line2+0.05, '**') elseif pv3 <= 0.001 text(mean(xt(1:3))-0.15, line2+0.05, '***') else text(mean(xt(1:3))-0.05, line2+0.1, 'ns','FontSize',8) end if pv4 <= 0.05 && pv4 > 0.01 text(mean(xt(2:4))-0.025, line3+0.05, '*') elseif pv4 <=0.01 && pv4 > 0.001 text(mean(xt(2:4))-0.05, line3+0.05, '**') elseif pv4 <= 0.001 text(mean(xt(2:4))-0.15, line3+0.05, '***') else text(mean(xt(2:4))-0.05, line3+0.1, 'ns','FontSize',8) end %% plotting number 3 figure(3); set(gcf,'Position',[400 200 wid hei]) ax = axes(); hold(ax); for i=1:4 h=boxchart(x(i)*ones(size(y3(:,i))), y3(:,i), 'BoxFaceColor', colors(i,:),'Notch','on'); h.MarkerStyle='.'; h.MarkerColor=colors(i,:); end hold on plot(1:2,nanmedian(y3(:,1:2)),'-o','LineWidth',1,'Color',blue,'MarkerSize',3,'MarkerFaceColor',blue) plot(3:4,nanmedian(y3(:,3:4)),'-o','LineWidth',1,'Color',red,'MarkerSize',3,'MarkerFaceColor',red) hold off xlim([0.5 4.5]) ylabel('s.s.s.') xticklabels({'ech','com','ech','com'}); set(gca, 'box', 'off') set(gca, 'Color','none') set(gca,'linewidth',1);set(gca,'fontsize',8); %% add stats pv1=signrank(y3(:,1),y3(:,2)); pv2=signrank(y3(:,3),y3(:,4)); pv3=ranksum(y3(:,1),y3(:,3)); pv4=ranksum(y3(:,2),y3(:,4)); pv5=signrank(y3(:,1)); pv6=signrank(y3(:,2)); pv7=signrank(y3(:,3)); pv8=signrank(y3(:,4)); xt = get(gca, 'XTick'); % plot lines for comparison line1=0.45; hold on plot(xt(1:2), [1 1]*line1, '-k','LineWidth',sl) plot([1;1]*xt(1),[line1,line1-0.03],'-k', 'LineWidth',sl); plot([1;1]*xt(2),[line1,line1-0.03],'-k', 'LineWidth',sl); plot(xt(3:4), [1 1]*line1, '-k','LineWidth',sl) plot([1;1]*xt(3),[line1,line1-0.03],'-k', 'LineWidth',sl); plot([1;1]*xt(4),[line1,line1-0.03],'-k', 'LineWidth',sl); ylim([-0.5 0.55]) % plot level of significance if pv1 <= 0.05 && pv1 > 0.01 text(mean(xt(1:2))-0.025, line1+0.05, '*') elseif pv1 <=0.01 && pv1 > 0.001 text(mean(xt(1:2))-0.05, line1+0.05, '**') elseif pv1 <= 0.001 text(mean(xt(1:2))-0.15, line1+0.05, '***') else text(mean(xt(1:2))-0.05, line1+0.1, 'ns','FontSize',8) end if pv2 <= 0.05 && pv2 > 0.01 text(mean(xt(3:4))-0.025, line1+0.05, '*') elseif pv2 <=0.01 && pv2 > 0.001 text(mean(xt(3:4))-0.05, line1+0.05, '**') elseif pv2 <= 0.001 text(mean(xt(3:4))-0.15, line1+0.05, '***') else text(mean(xt(3:4))-0.05, line1+0.1, 'ns','FontSize',8) end % add stats against null distribution line0=-0.45; if pv5 <= 0.05 && pv5 > 0.01 text(xt(1), line0, '*','HorizontalAlignment','center') elseif pv5 <=0.01 && pv5 > 0.001 text(xt(1), line0, '**','HorizontalAlignment','center') elseif pv5 <= 0.001 text(xt(1), line0, '***','HorizontalAlignment','center') else text(xt(1), line0, 'ns','FontSize',8,'HorizontalAlignment','center') end if pv6 <= 0.05 && pv6 > 0.01 text(xt(2), line0, '*','HorizontalAlignment','center') elseif pv6 <=0.01 && pv6 > 0.001 text(xt(2), line0, '**','HorizontalAlignment','center') elseif pv6 <= 0.001 text(xt(2), line0, '***','HorizontalAlignment','center') else text(xt(2), line0, 'ns','FontSize',8,'HorizontalAlignment','center') end if pv7 <= 0.07 && pv7 > 0.01 text(xt(3), line0, '*','HorizontalAlignment','center') elseif pv7 <=0.01 && pv7 > 0.001 text(xt(3), line0, '**','HorizontalAlignment','center') elseif pv7 <= 0.001 text(xt(3), line0, '***','HorizontalAlignment','center') else text(xt(3), line0, 'ns','FontSize',8,'HorizontalAlignment','center') end if pv8 <= 0.05 && pv8 > 0.01 text(xt(4), line0, '*','HorizontalAlignment','center') elseif pv8 <=0.01 && pv8 > 0.001 text(xt(4), line0, '**','HorizontalAlignment','center') elseif pv8 <= 0.001 text(xt(4), line0, '***','HorizontalAlignment','center') else text(xt(4), line0+0.03, 'ns','FontSize',8,'HorizontalAlignment','center') end % l=yline(0,'Color',[0.6 0.6 0.6], 'LineWidth',2); % uistack(l,'bottom')