Fig6C-Fig7A-B.m 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. close all;
  2. clear;
  3. % boxplots for context effect index
  4. load('all_ce.mat')
  5. aw_=all_ce(:,1)==1; n_aw=sum(aw_);
  6. an_=all_ce(:,1)==2; n_an=sum(an_);
  7. chi_=all_ce(:,1)==3; n_chi=sum(chi_);
  8. nav=all_ce(:,2:3);
  9. com=all_ce(:,4:5);
  10. % comparisons
  11. y1=nan(117,4);
  12. y2=nan(117,4);
  13. y1(1:n_aw,1:2)=nav(aw_,:);
  14. y1(1:n_an,3:4)=nav(an_,:);
  15. y2(1:n_aw,1:2)=com(aw_,:);
  16. y2(1:n_an,3:4)=com(an_,:);
  17. y3=[(y1(:,2)-y1(:,1))./2,(y2(:,2)-y2(:,1))./2,(y1(:,4)-y1(:,3))./2,(y2(:,4)-y2(:,3))./2] ;
  18. %% plotting
  19. red =[0.8500,0.3250, 0.0980];
  20. blue=[0,0.4470,0.7410];
  21. red_light=[1,0.5,0.5].*red;
  22. blue_light=[1,0.5,0.5].*blue;
  23. colors=[blue;blue_light;red;red_light];
  24. wid=160;
  25. hei=180;
  26. x = 1:4;
  27. figure(1); set(gcf,'Position',[400 200 wid hei])
  28. ax = axes();
  29. hold(ax);
  30. for i=1:4
  31. h=boxchart(x(i)*ones(size(y1(:,i))), y1(:,i), 'BoxFaceColor', colors(i,:),'Notch','on');
  32. h.MarkerStyle='.';
  33. h.MarkerColor=colors(i,:);
  34. end
  35. hold on
  36. plot(1:2,nanmedian(y1(:,1:2)),'-o','LineWidth',1,'Color',blue,'MarkerSize',3,'MarkerFaceColor',blue)
  37. plot(3:4,nanmedian(y1(:,3:4)),'-o','LineWidth',1,'Color',red,'MarkerSize',3,'MarkerFaceColor',red)
  38. hold off
  39. xlim([0.5 4.5])
  40. ylabel('echolocation effect')
  41. xticklabels({'match','mismatch','match','mismatch'});
  42. set(gca, 'box', 'off')
  43. set(gca, 'Color','none')
  44. set(gca,'linewidth',1);set(gca,'fontsize',8);
  45. %% add stats
  46. pv1=signrank(y1(:,1),y1(:,2));
  47. pv2=signrank(y1(:,3),y1(:,4));
  48. pv3=ranksum(y1(:,1),y1(:,3));
  49. pv4=ranksum(y1(:,2),y1(:,4));
  50. xt = get(gca, 'XTick');
  51. line1=0.45;
  52. line2=0.65;
  53. line3=0.85;
  54. sl=0.75;
  55. % plot lines for comparison
  56. hold on
  57. plot(xt(1:2), [1 1]*line1, '-k','LineWidth',sl)
  58. plot([1;1]*xt(1),[line1,line1-0.05],'-k', 'LineWidth',sl);
  59. plot([1;1]*xt(2),[line1,line1-0.05],'-k', 'LineWidth',sl);
  60. plot(xt(3:4), [1 1]*line1, '-k','LineWidth',sl)
  61. plot([1;1]*xt(3),[line1,line1-0.05],'-k', 'LineWidth',sl);
  62. plot([1;1]*xt(4),[line1,line1-0.05],'-k', 'LineWidth',sl);
  63. plot([xt(1) xt(3)], [1 1]*line2, '-k','LineWidth',sl)
  64. plot([1;1]*xt(1),[line2,line2-0.05],'-k', 'LineWidth',sl);
  65. plot([1;1]*xt(3),[line2,line2-0.05],'-k', 'LineWidth',sl);
  66. plot([xt(2) xt(4)], [1 1]*line3, '-k','LineWidth',sl)
  67. plot([1;1]*xt(2),[line3,line3-0.05],'-k', 'LineWidth',sl);
  68. plot([1;1]*xt(4),[line3,line3-0.05],'-k', 'LineWidth',sl);
  69. ylim([-1 1])
  70. % plot level of significance
  71. if pv1 <= 0.05 && pv1 > 0.01
  72. text(mean(xt(1:2))-0.025, line1+0.05, '*')
  73. elseif pv1 <=0.01 && pv1 > 0.001
  74. text(mean(xt(1:2))-0.05, line1+0.05, '**')
  75. elseif pv1 <= 0.001
  76. text(mean(xt(1:2))-0.15, line1+0.05, '***')
  77. else
  78. text(mean(xt(1:2))-0.05, line1+0.1, 'ns','FontSize',8)
  79. end
  80. if pv2 <= 0.05 && pv2 > 0.01
  81. text(mean(xt(3:4))-0.025, line1+0.05, '*')
  82. elseif pv2 <=0.01 && pv2 > 0.001
  83. text(mean(xt(3:4))-0.05, line1+0.05, '**')
  84. elseif pv2 <= 0.001
  85. text(mean(xt(3:4))-0.15, line1+0.05, '***')
  86. else
  87. text(mean(xt(3:4))-0.05, line1+0.1, 'ns','FontSize',8)
  88. end
  89. if pv3 <= 0.05 && pv3 > 0.01
  90. text(mean(xt(1:3))-0.025, line2+0.05, '*')
  91. elseif pv3 <=0.01 && pv3 > 0.001
  92. text(mean(xt(1:3))-0.05, line2+0.05, '**')
  93. elseif pv3 <= 0.001
  94. text(mean(xt(1:3))-0.15, line2+0.05, '***')
  95. else
  96. text(mean(xt(1:3))-0.05, line2+0.1, 'ns','FontSize',8)
  97. end
  98. if pv4 <= 0.05 && pv4 > 0.01
  99. text(mean(xt(2:4))-0.025, line3+0.05, '*')
  100. elseif pv4 <=0.01 && pv4 > 0.001
  101. text(mean(xt(2:4))-0.05, line3+0.05, '**')
  102. elseif pv4 <= 0.001
  103. text(mean(xt(2:4))-0.15, line3+0.05, '***')
  104. else
  105. text(mean(xt(2:4))-0.05, line3+0.1, 'ns','FontSize',8)
  106. end
  107. %% plotting number 2
  108. figure(2); set(gcf,'Position',[400 200 wid hei])
  109. ax = axes();
  110. hold(ax);
  111. for i=1:4
  112. h=boxchart(x(i)*ones(size(y2(:,i))), y2(:,i), 'BoxFaceColor', colors(i,:),'Notch','on');
  113. h.MarkerStyle='.';
  114. h.MarkerColor=colors(i,:);
  115. end
  116. hold on
  117. plot(1:2,nanmedian(y2(:,1:2)),'-o','LineWidth',1,'Color',blue,'MarkerSize',3,'MarkerFaceColor',blue)
  118. plot(3:4,nanmedian(y2(:,3:4)),'-o','LineWidth',1,'Color',red,'MarkerSize',3,'MarkerFaceColor',red)
  119. hold off
  120. xlim([0.5 4.5])
  121. ylabel('communication effect')
  122. xticklabels({'match','mismatch','match','mismatch'});
  123. set(gca, 'box', 'off')
  124. set(gca, 'Color','none')
  125. set(gca,'linewidth',1);set(gca,'fontsize',8);
  126. %% add stats
  127. pv1=signrank(y2(:,1),y2(:,2));
  128. pv2=signrank(y2(:,3),y2(:,4));
  129. pv3=ranksum(y2(:,1),y2(:,3));
  130. pv4=ranksum(y2(:,2),y2(:,4));
  131. xt = get(gca, 'XTick');
  132. % plot lines for comparison
  133. hold on
  134. plot(xt(1:2), [1 1]*line1, '-k','LineWidth',sl)
  135. plot([1;1]*xt(1),[line1,line1-0.05],'-k', 'LineWidth',sl);
  136. plot([1;1]*xt(2),[line1,line1-0.05],'-k', 'LineWidth',sl);
  137. plot(xt(3:4), [1 1]*line1, '-k','LineWidth',sl)
  138. plot([1;1]*xt(3),[line1,line1-0.05],'-k', 'LineWidth',sl);
  139. plot([1;1]*xt(4),[line1,line1-0.05],'-k', 'LineWidth',sl);
  140. plot([xt(1) xt(3)], [1 1]*line2, '-k','LineWidth',sl)
  141. plot([1;1]*xt(1),[line2,line2-0.05],'-k', 'LineWidth',sl);
  142. plot([1;1]*xt(3),[line2,line2-0.05],'-k', 'LineWidth',sl);
  143. plot([xt(2) xt(4)], [1 1]*line3, '-k','LineWidth',sl)
  144. plot([1;1]*xt(2),[line3,line3-0.05],'-k', 'LineWidth',sl);
  145. plot([1;1]*xt(4),[line3,line3-0.05],'-k', 'LineWidth',sl);
  146. ylim([-1 1])
  147. % plot level of significance
  148. if pv1 <= 0.05 && pv1 > 0.01
  149. text(mean(xt(1:2))-0.025, line1+0.05, '*')
  150. elseif pv1 <=0.01 && pv1 > 0.001
  151. text(mean(xt(1:2))-0.05, line1+0.05, '**')
  152. elseif pv1 <= 0.001
  153. text(mean(xt(1:2))-0.15, line1+0.05, '***')
  154. else
  155. text(mean(xt(1:2))-0.05, line1+0.1, 'ns','FontSize',8)
  156. end
  157. if pv2 <= 0.05 && pv2 > 0.01
  158. text(mean(xt(3:4))-0.025, line1+0.05, '*')
  159. elseif pv2 <=0.01 && pv2 > 0.001
  160. text(mean(xt(3:4))-0.05, line1+0.05, '**')
  161. elseif pv2 <= 0.001
  162. text(mean(xt(3:4))-0.15, line1+0.05, '***')
  163. else
  164. text(mean(xt(3:4))-0.05, line1+0.1, 'ns','FontSize',8)
  165. end
  166. if pv3 <= 0.05 && pv3 > 0.01
  167. text(mean(xt(1:3))-0.025, line2+0.05, '*')
  168. elseif pv3 <=0.01 && pv3 > 0.001
  169. text(mean(xt(1:3))-0.05, line2+0.05, '**')
  170. elseif pv3 <= 0.001
  171. text(mean(xt(1:3))-0.15, line2+0.05, '***')
  172. else
  173. text(mean(xt(1:3))-0.05, line2+0.1, 'ns','FontSize',8)
  174. end
  175. if pv4 <= 0.05 && pv4 > 0.01
  176. text(mean(xt(2:4))-0.025, line3+0.05, '*')
  177. elseif pv4 <=0.01 && pv4 > 0.001
  178. text(mean(xt(2:4))-0.05, line3+0.05, '**')
  179. elseif pv4 <= 0.001
  180. text(mean(xt(2:4))-0.15, line3+0.05, '***')
  181. else
  182. text(mean(xt(2:4))-0.05, line3+0.1, 'ns','FontSize',8)
  183. end
  184. %% plotting number 3
  185. figure(3); set(gcf,'Position',[400 200 wid hei])
  186. ax = axes();
  187. hold(ax);
  188. for i=1:4
  189. h=boxchart(x(i)*ones(size(y3(:,i))), y3(:,i), 'BoxFaceColor', colors(i,:),'Notch','on');
  190. h.MarkerStyle='.';
  191. h.MarkerColor=colors(i,:);
  192. end
  193. hold on
  194. plot(1:2,nanmedian(y3(:,1:2)),'-o','LineWidth',1,'Color',blue,'MarkerSize',3,'MarkerFaceColor',blue)
  195. plot(3:4,nanmedian(y3(:,3:4)),'-o','LineWidth',1,'Color',red,'MarkerSize',3,'MarkerFaceColor',red)
  196. hold off
  197. xlim([0.5 4.5])
  198. ylabel('s.s.s.')
  199. xticklabels({'ech','com','ech','com'});
  200. set(gca, 'box', 'off')
  201. set(gca, 'Color','none')
  202. set(gca,'linewidth',1);set(gca,'fontsize',8);
  203. %% add stats
  204. pv1=signrank(y3(:,1),y3(:,2));
  205. pv2=signrank(y3(:,3),y3(:,4));
  206. pv3=ranksum(y3(:,1),y3(:,3));
  207. pv4=ranksum(y3(:,2),y3(:,4));
  208. pv5=signrank(y3(:,1));
  209. pv6=signrank(y3(:,2));
  210. pv7=signrank(y3(:,3));
  211. pv8=signrank(y3(:,4));
  212. xt = get(gca, 'XTick');
  213. % plot lines for comparison
  214. line1=0.45;
  215. hold on
  216. plot(xt(1:2), [1 1]*line1, '-k','LineWidth',sl)
  217. plot([1;1]*xt(1),[line1,line1-0.03],'-k', 'LineWidth',sl);
  218. plot([1;1]*xt(2),[line1,line1-0.03],'-k', 'LineWidth',sl);
  219. plot(xt(3:4), [1 1]*line1, '-k','LineWidth',sl)
  220. plot([1;1]*xt(3),[line1,line1-0.03],'-k', 'LineWidth',sl);
  221. plot([1;1]*xt(4),[line1,line1-0.03],'-k', 'LineWidth',sl);
  222. ylim([-0.5 0.55])
  223. % plot level of significance
  224. if pv1 <= 0.05 && pv1 > 0.01
  225. text(mean(xt(1:2))-0.025, line1+0.05, '*')
  226. elseif pv1 <=0.01 && pv1 > 0.001
  227. text(mean(xt(1:2))-0.05, line1+0.05, '**')
  228. elseif pv1 <= 0.001
  229. text(mean(xt(1:2))-0.15, line1+0.05, '***')
  230. else
  231. text(mean(xt(1:2))-0.05, line1+0.1, 'ns','FontSize',8)
  232. end
  233. if pv2 <= 0.05 && pv2 > 0.01
  234. text(mean(xt(3:4))-0.025, line1+0.05, '*')
  235. elseif pv2 <=0.01 && pv2 > 0.001
  236. text(mean(xt(3:4))-0.05, line1+0.05, '**')
  237. elseif pv2 <= 0.001
  238. text(mean(xt(3:4))-0.15, line1+0.05, '***')
  239. else
  240. text(mean(xt(3:4))-0.05, line1+0.1, 'ns','FontSize',8)
  241. end
  242. % add stats against null distribution
  243. line0=-0.45;
  244. if pv5 <= 0.05 && pv5 > 0.01
  245. text(xt(1), line0, '*','HorizontalAlignment','center')
  246. elseif pv5 <=0.01 && pv5 > 0.001
  247. text(xt(1), line0, '**','HorizontalAlignment','center')
  248. elseif pv5 <= 0.001
  249. text(xt(1), line0, '***','HorizontalAlignment','center')
  250. else
  251. text(xt(1), line0, 'ns','FontSize',8,'HorizontalAlignment','center')
  252. end
  253. if pv6 <= 0.05 && pv6 > 0.01
  254. text(xt(2), line0, '*','HorizontalAlignment','center')
  255. elseif pv6 <=0.01 && pv6 > 0.001
  256. text(xt(2), line0, '**','HorizontalAlignment','center')
  257. elseif pv6 <= 0.001
  258. text(xt(2), line0, '***','HorizontalAlignment','center')
  259. else
  260. text(xt(2), line0, 'ns','FontSize',8,'HorizontalAlignment','center')
  261. end
  262. if pv7 <= 0.07 && pv7 > 0.01
  263. text(xt(3), line0, '*','HorizontalAlignment','center')
  264. elseif pv7 <=0.01 && pv7 > 0.001
  265. text(xt(3), line0, '**','HorizontalAlignment','center')
  266. elseif pv7 <= 0.001
  267. text(xt(3), line0, '***','HorizontalAlignment','center')
  268. else
  269. text(xt(3), line0, 'ns','FontSize',8,'HorizontalAlignment','center')
  270. end
  271. if pv8 <= 0.05 && pv8 > 0.01
  272. text(xt(4), line0, '*','HorizontalAlignment','center')
  273. elseif pv8 <=0.01 && pv8 > 0.001
  274. text(xt(4), line0, '**','HorizontalAlignment','center')
  275. elseif pv8 <= 0.001
  276. text(xt(4), line0, '***','HorizontalAlignment','center')
  277. else
  278. text(xt(4), line0+0.03, 'ns','FontSize',8,'HorizontalAlignment','center')
  279. end
  280. % l=yline(0,'Color',[0.6 0.6 0.6], 'LineWidth',2);
  281. % uistack(l,'bottom')