plotBarVariance.m 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. function plotBarVariance(widthCell, figDir, threshold, rSquareThreshold, varargin)
  2. switch nargin
  3. case 4
  4. categoryLabels = {'X OFF', 'Y OFF', 'X ON', 'Y ON'};
  5. nameSuffix = '';
  6. axLims = [];
  7. case 5
  8. categoryLabels = varargin{1};
  9. nameSuffix = '';
  10. axLims = [];
  11. case 6
  12. categoryLabels = varargin{1};
  13. nameSuffix = varargin{2};
  14. axLims = [];
  15. case 7
  16. categoryLabels = varargin{1};
  17. nameSuffix = varargin{2};
  18. axLims = varargin{3};
  19. otherwise
  20. end
  21. %% Variance plot
  22. qualityMeasure = 'responseQuality';
  23. hFig = createPrintFig(5 * [1 0.7]);
  24. hAx = gca;
  25. varianceArray = cellfun(@var, widthCell);
  26. stdArray = cellfun(@std, widthCell);
  27. hBars = bar(stdArray);
  28. % Formatting.
  29. colors = getONOFFXYColors;
  30. if numel(widthCell) > 4
  31. colors = repmat(colors, ceil(numel(widthCell) / 4), 1);
  32. end
  33. hBars.FaceColor = 'flat';
  34. hBars.CData = colors(1: numel(widthCell), :);
  35. hBars.LineStyle = 'none';
  36. hBars.Horizontal = 'off';
  37. ylabel('std (\circ)');
  38. hAx.XTick = 1: numel(widthCell);
  39. hAx.XTickLabel = categoryLabels;
  40. prettifyAxes(hAx);
  41. offsetAxes(hAx);
  42. setFontForThesis(hAx, hFig);
  43. if ~isempty(axLims)
  44. hAx.YLim = axLims;
  45. end
  46. figFileName = ['fhwmStd-' nameSuffix qualityMeasure '-' num2str(threshold) ...
  47. '-rSquare-' num2str(rSquareThreshold)];
  48. % set(gcf,'renderer','painters')
  49. % set(gcf, 'PaperPositionMode', 'auto');
  50. print(hFig, [figDir figFileName '.pdf'], '-dpdf')
  51. print(hFig, [figDir figFileName '.png'], '-dpng', '-r300')
  52. end