% file: build_plots.m
%
% this script requires no arguments
%
% this script creates all of the plots used to analyze the principal components
% algorithm as applied to the two class problem defined. this script creates
% a total of 5 figures:
%   1. plot of original sets in the euclidean space with lines showing
%         where samples fall equidistant from both sets both in the original
%         space and after transformation.
%   2. plot of the sets transformed into the new space.
%   4. plot of T1(x-u) for set 1
%   5. plot of T2(x-u) for set 2
%

% close all of the open figures
%
close all;

%*****************************************************************************
%
% plot original data sets and equidistant lines for the original space and
% the transformed space
%
%*****************************************************************************
%
% open up a new figure and save the plot handle
%
euclidean_figure = figure;

% plot both data sets from the original space to a single plot. set 1 will be
% indicated by circles, set 2 is indicated by stars
%
plot(euclid_set_1(:,1), euclid_set_1(:,2), 'ko');
hold on;
plot(euclid_set_2(:,1), euclid_set_2(:,2), 'k*');

% adjust the axes and add grid lines
%
axis([-5 5 -5 5]);
grid on;
set(gca, 'XTick', [-5:1:5]);

% plot the sample points on the current graph
%
hold on;
plot(euclid_sample_set(:,1), euclid_sample_set(:,2), 'ks');
hold on;

% plot the line which divides the two spaces
%
plot_dividing_orig;

% plot the dividing line in the original space
%
plot_div_orig_from_xform;

% title the graph and add a legend
%
title('Sets 1 and 2 in Euclidean Space');
legend('Set 1', 'Set 2', 'Samples', 'Equally Likely in Space', 'Equally Likely in XForm Space');
hold on;

%*****************************************************************************
%
% plot transformed data sets and equidistant curves in the transformed space
%
%*****************************************************************************
%
% create a new figure for these plots
%
transform_figure_1 = figure;

% plot the transformed sets 1 and 2. set 1 is represented by circles, set 2 is
% represented by stars
%
plot(set_1_xform(:,1), set_1_xform(:,2), 'ko');
hold on;
plot(set_2_xform(:,1), set_2_xform(:,2), 'k*');
hold on;

% plot the sample points as transformed by the two transforms
%
plot(sample_set_1_xform(:,1), sample_set_1_xform(:,2), 'kv');
hold on;
plot(sample_set_2_xform(:,1), sample_set_2_xform(:,2), 'ks');
hold on;

% adjust the axes and add grid lines
%
axis fill;
grid on;
ax = axis;
xmin = round(ax(1));
xmax = round(ax(2));
set(gca, 'XTick', [xmin:1:xmax]);

% title the plot and build a legend
%
title('Sets 1 and 2 in the Transformed Space');
legend('Set 1', 'Set 2', 'Samples in set 1 space', 'Samples in set 2 space');
hold on;

% create a new figure for a new set of plots
%
transform_figure_2 = figure;

% plot the transformed sets 1 and 2. set 1 is represented by circles, set 2 is
% represented by stars
%
plot(set_1_xform(:,1), set_1_xform(:,2), 'ko');
hold on;
plot(set_2_xform(:,1), set_2_xform(:,2), 'k*');
hold on;

% adjust the axes and add grid lines
%
axis fill;
grid on;
ax = axis;
xmin = round(ax(1));
xmax = round(ax(2));
set(gca, 'XTick', [xmin:1:xmax]);

% title the plot and build a legend
%
title('Boundaries of sets 1 and 2 in the Transformed Space');
legend('Set 1', 'Set 2');
hold on;


%*****************************************************************************
%
% plot T(x-u) for each set
%
%*****************************************************************************
%
% plot the transformed T(x-u) for set 1
%
figure;
plot(xform_x_sub_mean_1(:,1), xform_x_sub_mean_1(:,2),'ko');
title('y = T(x-u) for set 1');

% plot the transformed T(x-u) for set 2
%
figure;
plot(xform_x_sub_mean_2(:,1), xform_x_sub_mean_2(:,2),'k*');
title('y = T(x-u) for set 2');

% end of script
%







