function plotPareto(X,Y,init_dataset_size,initdesignfile,motorProps,settingsMagnetostatic,designFunction,y_refdesign,labelObjective,Xlimits,Ylimits,Zlimits,Userdata)

if exist('labelObjective','var') && ~isempty(labelObjective)
    if ~iscell(labelObjective)
    	error('labelObjective must be cell array containing 2 or 3 objectives');  
    end
    nObjectives = length(labelObjective);
else
    nObjectives = 2;
end
if nObjectives~=2 && nObjectives~=3
    error('labelObjective must be cell array containing 2 or 3 objectives');
end
Fig = figure;
data.X = X;
data.Y = Y;
data.initdesignfile = initdesignfile;
data.motorProps = motorProps;
data.settingsMagnetostatic = settingsMagnetostatic;
data.designFunction = designFunction;
savepath = fileparts(initdesignfile);
data.savepath = savepath;
if ~exist('Userdata','var')
    Userdata=[];
end
data.Userdata = Userdata;
set(Fig,'UserData',data);
hold on
if nObjectives==2
    p1 = plot(Y(1:init_dataset_size,1),Y(1:init_dataset_size,2),'.','MarkerSize',14,'Color','b');
    p2 = plot(Y(init_dataset_size+1:end,1),Y(init_dataset_size+1:end,2),'x','MarkerSize',8,'LineWidth',2,'Color','g');
%     p3 = plot(Ypareto(:,1),Ypareto(:,2),'O','MarkerSize',8,'LineWidth',2,'Color','c');
elseif nObjectives==3
    if exist('Zlimits','var') && ~isempty(Zlimits)
        if length(Zlimits)==1
            % Zlimits defines only upper limit
            Zlimit_upper = Zlimits;
        else
            % Zlimits defines lower and upper limit
            Zlimit_lower = Zlimits(1);
            Y(Y(:,3)<Zlimit_lower,3)=Zlimit_lower;
            Zlimit_upper = Zlimits(2);
        end    
        Y(Y(:,3)>Zlimit_upper,3)=Zlimit_upper;
    end
    p1 = scatter(Y(:,1),Y(:,2),25,Y(:,3),'filled');
    c = colorbar;
    p2=p1; p3=p1;
end
if ~isempty(p1)
    p1.UIContextMenu = ParetoMXPrightclickmenu(1);
end
p2.UIContextMenu = ParetoMXPrightclickmenu(1);
p3.UIContextMenu = ParetoMXPrightclickmenu(1);
if ~isempty(y_refdesign)
    plot(y_refdesign(1),y_refdesign(2),'x','MarkerSize',8,'LineWidth',2,'Color','r');
end
Axes=gca;
Axes.UIContextMenu = ParetoMXPrightclickmenu(2);
if nObjectives==2
    if ~isempty(y_refdesign)
        if init_dataset_size>0
            legend('Initial designs (LHC)','Generated designs','Reference design','Location','Northeast');
        else
            legend('Generated designs','Reference design','Location','Northeast');
        end
    else
        if init_dataset_size>0
            legend('Initial designs (LHC)','Generated designs','Location','Northeast');
        else
            legend('Generated designs','Location','Northeast');
        end
    end
elseif nObjectives==3
    if ~isempty(y_refdesign)
        legend('Generated designs','Reference design','Location','Northeast');
    end
end
title('Results TS-EMO algorithm')
if exist('labelObjective','var') && ~isempty(labelObjective)
    xlabel(labelObjective{1});
    if length(labelObjective)>1
        ylabel(labelObjective{2});
        if length(labelObjective)>2
            c.Label.String = labelObjective{3};
        end
    end
else
    xlabel('f_1')
    ylabel('f_2')
end
if exist('Xlimits','var') && ~isempty(Xlimits)
    if length(Xlimits)==1
        % Xlimits defines only upper limit
        Xlimit_upper = Xlimits;
        xlim auto
        Xlimits = xlim;
        Xlimits(2) = Xlimit_upper;
        xlim(Xlimits);
    elseif length(Xlimits)==2
        % Xlimits defines lower and upper limits
        xlim(Xlimits);
    end
end
if exist('Ylimits','var') && ~isempty(Ylimits)
    if length(Ylimits)==1
        % Ylimits defines only upper limit
        Ylimit_upper = Ylimits;
        ylim auto
        Ylimits = ylim;
        Ylimits(2) = Ylimit_upper;
        ylim(Ylimits);
    elseif length(Ylimits)==2
        % Ylimits defines lower and upper limits
        ylim(Ylimits);
    end
end
    

grid
hold off

