plot4lines.m 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. function plot4lines(time,a,colores,xl,yl,legend1,legend2,legend3,legend4,titu,simple,legtitles,addingcluster,timesignclust,coloresclus)
  2. a_plot(8)=fill([2000 2350 2000 2350],[20 20 0 0],'k','LineStyle','none','FaceAlpha',0.2);hold on;
  3. a_plot(9)=fill([0 500 0 500],[20 20 0 0],'k','LineStyle','none','FaceAlpha',0.10);hold on;
  4. a_plot(10)=fill([1000 1500 1000 1500],[20 20 0 0],'k','LineStyle','none','FaceAlpha',0.10);hold on;
  5. for pl=[4 3 2 1];
  6. dia_acc=a{pl}
  7. timetoplot=time(150:end);
  8. mean_da=nanmean(dia_acc(150:end,:),2);
  9. sem_da=nanstd(dia_acc(150:end,:),0,2)/sqrt(sum(~isnan(dia_acc(1,:))));
  10. line([timetoplot(1),timetoplot(end)], [0,0], 'Color', 'k','LineStyle','-','LineWidth',2);hold on;
  11. % line([timetoplot(1),timetoplot(end)], [chancelevel,chancelevel], 'Color', 'k','LineStyle','--');hold on;
  12. a_plot(pl)=plot(timetoplot,mean_da,'Color',colores(pl,:),'LineWidth',3);hold on;
  13. fill([timetoplot,flipdim(timetoplot,2),timetoplot(1)],[mean_da+sem_da;flipdim(mean_da-sem_da,1);mean_da(1)+sem_da(1)],colores(pl,:),'LineStyle','none','FaceAlpha',0.30);
  14. hold on
  15. end
  16. a_plot(5)=line([0,0],[-10 10], 'Color', 'k','LineStyle',':','LineWidth',2);hold on;
  17. a_plot(6)=line([1000,1000],[-10 10], 'Color', 'k','LineStyle',':','LineWidth',2);hold on;
  18. % a_plot(7)=line([2000,2000],[-10 10], 'Color', 'k','LineStyle','--','LineWidth',2);hold on;
  19. %%
  20. if addingcluster
  21. % Adding lines of cluster perm test
  22. strp=-0.01;
  23. dist=0.0075;
  24. for lll=1:size(timesignclust,1)
  25. clustertoplot=nan(size(time))
  26. t1=find(time==timesignclust(lll,1))
  27. t2=find((time==timesignclust(lll,2)))
  28. clustertoplot(t1:t2)=strp-dist*lll
  29. hold on;
  30. a_plot(10+lll)=plot(time,clustertoplot,'o',...
  31. 'MarkerSize',5,...
  32. 'MarkerEdgeColor',coloresclus(lll,:),...
  33. 'MarkerFaceColor',coloresclus(lll,:))
  34. legend('off')
  35. end
  36. end
  37. %%
  38. if simple==0
  39. legend([a_plot(1 ) a_plot(2) a_plot(3) a_plot(4) a_plot(5) a_plot(6) a_plot(7)],...
  40. legend1,legend2,legend3,legend4,'object 1 onset','object 2 onset','retrocue onset','Location','NorthEast')
  41. elseif simple==1
  42. if legtitles==0
  43. lgd= legend([a_plot(1 ) a_plot(2) a_plot(3) a_plot(4)],...
  44. legend1,legend2,legend3,legend4,'Location','NorthEast')
  45. lgd.NumColumns = 2
  46. end
  47. if legtitles==1
  48. lgd= legend([a_plot(1 ) a_plot(2) a_plot(3) a_plot(4)],...
  49. legend1,legend2,legend3,legend4,'Position',[520 100 0 350])
  50. lgd.NumColumns = 2;
  51. text(357,250,'Stimulus 1','Color','black','FontSize',14,'Units','pixel','HorizontalAlignment','center','FontSize',20,'FontWeight','bold')
  52. text(470,250,'Stimulus 2','Color','black','FontSize',14,'Units','pixel','HorizontalAlignment','center','FontSize',20,'FontWeight','bold')
  53. end
  54. end
  55. legend('boxoff')
  56. title([titu])
  57. xlim(xl)
  58. ylim(yl)
  59. xlabel('time (ms)')
  60. ylabel('rho')
  61. set(gca, 'box', 'off')
  62. end