Fig1L.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. %% Fig. 1L - Stacked bar chart
  2. clear
  3. close all
  4. % ========================================
  5. %% Stacked bar
  6. % ========================================
  7. %Prepare variables
  8. TotalCell = [837; 755; 808; 709];
  9. tempData4StackBar =...
  10. [486 136 167 48;
  11. 369 187 128 71;
  12. 465 119 164 60;
  13. 419 158 89 43];
  14. Data4StackBar = nan(4,4);
  15. for i=1:4
  16. Data4StackBar(i,:) = tempData4StackBar(i,:)/TotalCell(i);
  17. end
  18. %Initial learning----------------------------------------------------------
  19. fig1 = figure('Name', 'InitialLearning_CellRatio');
  20. fig1.Position = [410 278 160 220];
  21. StackedBar = bar(Data4StackBar(1:2, :),'stacked', 'FaceColor','flat');
  22. set(StackedBar,'EdgeColor', 'none');
  23. title('Initial');
  24. xticklabels({'Initial', 'Reversal'});
  25. ylim([0 1.1]);
  26. StackedBar(1).CData = [0.85 0.85 0.85];
  27. StackedBar(2).CData = [1 0 0];
  28. StackedBar(3).CData = [0 0.85 0];
  29. StackedBar(4).CData = [0 0 1];
  30. box off
  31. lgd = legend('Non.Resp','Go','Nogo','Both');
  32. lgd.Location = 'SouthEast';
  33. lgd.Box = 'off';
  34. hold on
  35. %Reversal learning---------------------------------------------------------
  36. fig2 = figure('Name', 'ReversalLearning_CellRatio');
  37. fig2.Position = [710 278 160 220];
  38. RevStack = bar(Data4StackBar(3:4, :),'stacked', 'FaceColor','flat');
  39. set(RevStack,'EdgeColor', 'none');
  40. title('Reversal');
  41. xticklabels({'Initial', 'Reversal'});
  42. ylim([0 1.1]);
  43. RevStack(1).CData = [0.85 0.85 0.85];
  44. RevStack(2).CData = [1 0 0];
  45. RevStack(3).CData = [0 0.85 0];
  46. RevStack(4).CData = [0 0 1];
  47. box off
  48. Revlgd = legend('Non.Resp','Go','Nogo','Both');
  49. Revlgd.Location = 'SouthEast';
  50. Revlgd.Box = 'off';
  51. hold on
  52. disp('Stacked bar chart plot finished')