function this = callPlotFcn(this, State)
%

%   Copyright 2016-2022 The MathWorks, Inc.

PlotFcn = this.PrivOptions.PlotFcn;
this.PlotFcnStop = false;
if ~isempty(PlotFcn)
    if ~iscell(PlotFcn)
        PlotFcn = {PlotFcn};
    end
    for i = 1:numel(PlotFcn)
        try
            stop = PlotFcn{i}(this, State);
        catch me
            bayesoptim.warn('PlotFcnError', i);
            bayesoptim.printInfo('ErrorDisplay');
            disp(me.message);
            stop = false;
        end
        if ~(isscalar(stop) && islogical(stop))
            bayesoptim.warn('PlotFcnOutput', i);
        end
        this.PlotFcnStop = this.PlotFcnStop || stop;
    end
    drawnow;
end
end
