Calculations/MOT Capture Process Simulation/+Plotting/plotResultForOneParameterScan.m

62 lines
2.5 KiB
Mathematica
Raw Normal View History

function plotResultForOneParameterScan(XParameter, YQuantity, varargin)
p = inputParser;
p.KeepUnmatched = true;
addRequired(p, 'ParameterArray', @isvector)
addRequired(p, 'QuantityOfInterestArray', @ismatrix)
addParameter(p, 'RescalingFactorForParameter', 1, @isscalar)
addParameter(p, 'XLabelString', 'X parameter', @ischar)
addParameter(p, 'ErrorsForYQuantity', false, @islogical)
addParameter(p, 'ErrorsArray', [], @isvector)
addParameter(p, 'RescalingFactorForYQuantity', 1, @isscalar)
addParameter(p, 'YLabelString', 'Y parameter', @ischar)
addParameter(p, 'TitleString', 'One-Parameter Scan', @ischar)
p.parse(XParameter, YQuantity, varargin{:})
XParameter = p.Results.ParameterArray;
RescalingFactorForXParameter = p.Results.RescalingFactorForParameter;
XLabelString = p.Results.XLabelString;
YQuantity = p.Results.QuantityOfInterestArray;
ErrorsForYQuantity = p.Results.ErrorsForYQuantity;
ErrorsArray = p.Results.ErrorsArray;
RescalingFactorForYQuantity = p.Results.RescalingFactorForYQuantity;
YLabelString = p.Results.YLabelString;
TitleString = p.Results.TitleString;
f_h = Helper.getFigureByTag('One-Parameter Scan');
set(groot,'CurrentFigure',f_h);
a_h = get(f_h, 'CurrentAxes');
if ~isempty(get(a_h, 'Children'))
clf(f_h);
end
f_h.Name = 'One-Parameter Scan';
f_h.Units = 'pixels';
set(0,'units','pixels');
screensize = get(0,'ScreenSize');
f_h.Position = [[screensize(3)/3.5 screensize(4)/3.5] 750 600];
RescaledXParameter = XParameter .* RescalingFactorForXParameter;
RescaledYQuantity = YQuantity .* RescalingFactorForYQuantity;
if ErrorsForYQuantity
RescaledErrorsArray = ErrorsArray .* RescalingFactorForYQuantity;
errorbar(RescaledXParameter, RescaledYQuantity, RescaledErrorsArray)
else
plot(RescaledXParameter, RescaledYQuantity, '--o', 'Linewidth', 1.5);
end
hXLabel = xlabel(XLabelString);
hYLabel = ylabel(YLabelString);
hTitle = sgtitle(TitleString);
set([hXLabel, hYLabel] , ...
'FontSize' , 14 );
set( hTitle , ...
'FontSize' , 18 );
Helper.bringFiguresWithTagInForeground();
end