When using the set function for Figure 2 and Figure 3,I had accidentally kept referring to the same plot name for Figure 1. Here is my corrected code.
%% The column vector, |species|, consists of iris flowers of three
% different species, setosa, versicolor, virginica. The double matrix
% |features| consists of four types of measurements on the flowers, the length
% and width of sepals and petals in centimeters, respectively.
features = xlsread("iris.xls", 2); %sepal length, sepal width, petal length, petal width
labels = xlsread("iris.xls", 3); % flower type classes
species = cell(size(labels));
species(labels==1)={'Setosa'};
species(labels==2)={'Versicolor'};
species(labels==3)={'Virginica'};
% The names of features are stored in an array.
feature_names = ["Sepal Length", "Sepal Width", "Petal Length", "Petal Width"];
%% Features
% Use petal length (third column in |features| ) and petal width (fourth column
% in |features| ) measurements. Save these as variables PL and PW,
% respectively.
% 4 features & 3 classes
SL = features(:,1);
SW = features(:,2);
PL = features(:,3);
PW = features(:,4);
%% Recall Original Iris Data
% Recall Iris Setosa
Class1 = features(1:50,:);
SLClass1 = features(1:50,1);
SWClass1 = features(1:50,2);
PLClass1 = features(1:50,3);
PWClass1 = features(1:50,4);
% Recall Iris Versicolor
Class2 = features(51:100,:);
SLClass2 = features(51:100,1);
SWClass2 = features(51:100,2);
PLClass2 = features(51:100,3);
PWClass2 = features(51:100,4);
% Recall Iris Virginica
Class3 = features(101:150,:);
SLClass3= features(101:150,1);
SWClass3= features(101:150,2);
PLClass3= features(101:150,3);
PWClass3= features(101:150,4);
%% Synthetic Data
%% Class 1 - SL vs. PW
% Plot Original Class 1 - Iris SL vs. PW.
figure
plotIris1 = scatter(SLClass1,PWClass1,'r')
hold on;
set(plotIris1,{'DisplayName'},{'Iris Data (red)'})
legend show;
title('Original Iris Data - Class 1 - Sepal Length vs. Petal Width');
xlabel('Sepal Length');
ylabel('Petal Width');
hold off;
%% Generate Random Data
% Create Random Data with 100 Additional Observations for Each Class
% Class 1 Randoms. Generate 100 extra observations. Random Data must be 100 x 4 and normally distributed.
Class1_r = randn(100,4);
%Class1_r = randi([0 1],100,4); % Randi did not create a truly random data.
SLClass1_r = Class1_r(:,1);
SWClass1_r = Class1_r(:,2);
PLClass1_r = Class1_r(:,3);
PWClass1_r = Class1_r(:,4);
a = min(SLClass1_r(:));
b = max(SLClass1_r(:));
ra = 0.0886;
rb = 0.4684;
SLClass1_Normalized = (((ra-rb) * (SLClass1_r - a)) / (b - a)) + rb;
a = min(PWClass1_r(:));
b = max(PWClass1_r(:));
ra = -0.9200;
rb = -0.5200;
PWClass1_Normalized = (((ra-rb) * (PWClass1_r - a)) / (b - a)) + rb;
% Plot Synthetic Data - Class 1 - SL vs. PW
figure(2)
Class1_Syntheticslpw = scatter(SLClass1_Normalized,PWClass1_Normalized,'b')
hold on;
set(Class1_Syntheticslpw,{'DisplayName'},{'Synthetic Iris Data (blue)'})
legend show
title('Synthetic Iris Data - Class 1 - Sepal Length vs. Petal Width');
xlabel('Sepal Length');
ylabel('Petal Width');
% Plot Combined Graphs - Class 1 - SL vs. PW
figure;
plotIris1 = scatter(SLClass1,PWClass1,'r')
set(plotIris1,{'DisplayName'},{'Iris Data (red)'})
hold on;
legend show
title('Class 1 - SL vs. PW - Original & Synthetic Data');
xlabel('Sepal Length');
ylabel('Petal Width');
Class1_Synthetic_slpw = scatter(SLClass1_Normalized,PWClass1_Normalized,'b')
set(Class1_Synthetic_slpw,{'DisplayName'},{'Synthetic Iris Data (blue)'})
legend show
hold off;