function plotBarVariance(widthCell, figDir, threshold, rSquareThreshold, varargin) switch nargin case 4 categoryLabels = {'X OFF', 'Y OFF', 'X ON', 'Y ON'}; nameSuffix = ''; axLims = []; case 5 categoryLabels = varargin{1}; nameSuffix = ''; axLims = []; case 6 categoryLabels = varargin{1}; nameSuffix = varargin{2}; axLims = []; case 7 categoryLabels = varargin{1}; nameSuffix = varargin{2}; axLims = varargin{3}; otherwise end %% Variance plot qualityMeasure = 'responseQuality'; hFig = createPrintFig(5 * [1 0.7]); hAx = gca; varianceArray = cellfun(@var, widthCell); stdArray = cellfun(@std, widthCell); hBars = bar(stdArray); % Formatting. colors = getONOFFXYColors; if numel(widthCell) > 4 colors = repmat(colors, ceil(numel(widthCell) / 4), 1); end hBars.FaceColor = 'flat'; hBars.CData = colors(1: numel(widthCell), :); hBars.LineStyle = 'none'; hBars.Horizontal = 'off'; ylabel('std (\circ)'); hAx.XTick = 1: numel(widthCell); hAx.XTickLabel = categoryLabels; prettifyAxes(hAx); offsetAxes(hAx); setFontForThesis(hAx, hFig); if ~isempty(axLims) hAx.YLim = axLims; end figFileName = ['fhwmStd-' nameSuffix qualityMeasure '-' num2str(threshold) ... '-rSquare-' num2str(rSquareThreshold)]; % set(gcf,'renderer','painters') % set(gcf, 'PaperPositionMode', 'auto'); print(hFig, [figDir figFileName '.pdf'], '-dpdf') print(hFig, [figDir figFileName '.png'], '-dpng', '-r300') end