% Plot 6

load([ModelLabel '_Plot_6_Data.mat'], 'Plot_6_Results', 'Plot_6_InitialPlot')

% Plot 6: 5000 Final opinion points: Different Initial Opinions

InitialOpinionIDs = InitialOpinionIDs_large;
AgentParametersIDs = AgentParametersIDs_small;

if id_model == 1
    DigraphIDs = 1;
else
    DigraphIDs = 1:size(InteractionNetworks,2);
end

disp([ 9 9 9 'Plot 6: 5000 Final opinion points: Different Initial Opinions PLOT'])    

switch id_model
    case 1 
        DigraphIDs = 1;
    case 2
        DigraphIDs = 1:9;
    case 3
        DigraphIDs = IntermediateDigraphIDs;
    case 4
        DigraphIDs = IntermediateDigraphIDs;
end

% Plot initial opinions
num_opinions = size(InitialOpinionIDs,2);
plot([0 1 1 0], [0 -1 1 0], '--k','LineWidth',1), hold on
plot([-2 2], [0 0], ':k','LineWidth',1.5)

for id_row_2 = 1:num_opinions


    x_value = Plot_6_InitialPlot{id_row_2}{1}(1);
    y_value = Plot_6_InitialPlot{id_row_2}{1}(2);
    localPointColor = Plot_6_InitialPlot{id_row_2}{2};
    
    plot(x_value, y_value, '.', 'Color', localPointColor, 'MarkerSize', 20), hold on

end

axis([-0.1 1.1 -1.1 1.1])
grid on
ylabel('mean(opinions)'), xlabel('mean(abs(opinions))')
set(gca, 'FontSize', 22)
title('Agreement Plot', 'fontsize', 27)


exportgraphics(Fig, [ './Chap/Opinion_Tools/Figures/' ModelLabel '/Plot_6/' ModelLabel '_InitialOpinionsReference.png']), pause(0.1), clf

local_counter = 0;
for id_di = 1:size(DigraphIDs,2)
    Aux_3_DigraphSelection

    for id_ap = 1:size(AgentParametersIDs,2)

        Aux_4_AgentParameterSelection
        Aux_8_PlotPreparation

        local_counter = local_counter + 1;

        SingleNameFigure = [ ModelLabel '_ParametricCurve_6_id_ap_' num2str(id_paramterer) '_id_di_' num2str(id_network) '.png' ];
        if CreateFigure(SingleNameFigure,AllFigures)

            
            disp([ 9 ' . ' num2str(local_counter) '/' num2str(size(AgentParametersIDs,2)*size(DigraphIDs,2))])

            Plot_6_LocalResults = Plot_6_Results{local_counter}{1};

            for id_row_2 = 1:num_opinions

                x_value = Plot_6_LocalResults{id_row_2}{1}(1);
                y_value = Plot_6_LocalResults{id_row_2}{1}(2);
                localPointColor = Plot_6_LocalResults{id_row_2}{2};
            
                plot(x_value, y_value, '.', 'Color', localPointColor, 'MarkerSize', 20), hold on

            end
            
            id_paramterer = Plot_6_Results{local_counter}{2}(1);
            id_network = Plot_6_Results{local_counter}{2}(2);
            
            Aux_9_PlotDetails

            exportgraphics(Fig, [ './Chap/Opinion_Tools/Figures/' ModelLabel '/Plot_6/' ModelLabel '_ParametricCurve_6_id_ap_' num2str(id_paramterer) '_id_di_' num2str(id_network) '.png']), pause(0.1), clf


            Aux_1_AgentParameterSuplot
            Aux_2_DigraphSubplot


        else

            disp([ 9 'Figure skipped'])

        end
        
        
        

    end
end