diff --git a/MOT Capture Process Simulation/+Plotting/plotResultForOneParameterScan.m b/MOT Capture Process Simulation/+Plotting/plotResultForOneParameterScan.m index 74ef9a5..7ff81c8 100644 --- a/MOT Capture Process Simulation/+Plotting/plotResultForOneParameterScan.m +++ b/MOT Capture Process Simulation/+Plotting/plotResultForOneParameterScan.m @@ -10,7 +10,10 @@ function plotResultForOneParameterScan(XParameter, YQuantity, varargin) addParameter(p, 'XLabelString', 'X parameter', @ischar) addParameter(p, 'ErrorsForYQuantity', false, @islogical) addParameter(p, 'ErrorsArray', [], @isvector) + addParameter(p, 'CIForYQuantity', false, @islogical) + addParameter(p, 'CIArray', [], @ismatrix) addParameter(p, 'RescalingFactorForYQuantity', 1, @isscalar) + addParameter(p, 'RemoveOutliers', false, @islogical) addParameter(p, 'YLabelString', 'Y parameter', @ischar) addParameter(p, 'TitleString', 'One-Parameter Scan', @ischar) @@ -22,7 +25,10 @@ function plotResultForOneParameterScan(XParameter, YQuantity, varargin) YQuantity = p.Results.QuantityOfInterestArray; ErrorsForYQuantity = p.Results.ErrorsForYQuantity; ErrorsArray = p.Results.ErrorsArray; + CIForYQuantity = p.Results.CIForYQuantity; + CIArray = p.Results.CIArray; RescalingFactorForYQuantity = p.Results.RescalingFactorForYQuantity; + RemoveOutliers = p.Results.RemoveOutliers; YLabelString = p.Results.YLabelString; TitleString = p.Results.TitleString; @@ -39,16 +45,37 @@ function plotResultForOneParameterScan(XParameter, YQuantity, varargin) screensize = get(0,'ScreenSize'); f_h.Position = [[screensize(3)/3.5 screensize(4)/3.5] 750 600]; + if RemoveOutliers + [YQuantity,TF] = rmoutliers(YQuantity); + XParameter = XParameter(~TF); + ErrorsArray = ErrorsArray(~TF); + ClippedCIArray(:,1) = CIArray(~TF,1); + ClippedCIArray(:,2) = CIArray(~TF,2); + CIArray = ClippedCIArray; + end + RescaledXParameter = XParameter .* RescalingFactorForXParameter; RescaledYQuantity = YQuantity .* RescalingFactorForYQuantity; - + + hold on + if ErrorsForYQuantity RescaledErrorsArray = ErrorsArray .* RescalingFactorForYQuantity; - errorbar(RescaledXParameter, RescaledYQuantity, RescaledErrorsArray) + errorbar(RescaledXParameter, RescaledYQuantity, RescaledErrorsArray, 'o', 'Linewidth', 1.5, 'MarkerFaceColor', '#0071BB') else plot(RescaledXParameter, RescaledYQuantity, '--o', 'Linewidth', 1.5); end + if CIForYQuantity + RescaledCIArray = CIArray .* RescalingFactorForYQuantity; + Plotting.plotConfidenceIntervalRegion(RescaledXParameter, RescaledCIArray(:,1), RescaledCIArray(:,2)); + end + + hold off + + xlim([0 inf]) + ylim([0 inf]) + hXLabel = xlabel(XLabelString); hYLabel = ylabel(YLabelString); hTitle = sgtitle(TitleString); @@ -58,5 +85,6 @@ function plotResultForOneParameterScan(XParameter, YQuantity, varargin) set( hTitle , ... 'FontSize' , 18 ); + grid on Helper.bringFiguresWithTagInForeground(); end \ No newline at end of file