Hi, I am working on the following code to plot three different classes:
% a - Plot the data in a two-dimensional vector space.
clc;clear;% Class 1
x1 = [16; 18; 20; 11; 17; 8; 14; 10; 4; 7;];y1 = [13; 13; 13; 12; 12; 11; 11; 10; 9; 9];class1 = [x1 y1];% Class 2
x2 = [8; 9; 6; 8; 5; 7; 4; 6; 4; 3];y2 = [8; 7; 7; 6; 5; 5; 4; 3; 2; 2]; class2 = [x2 y2];% Class 3
x3 = [19; 19; 17; 17; 16; 14; 13; 13; 11; 11];y3 = [6; 3; 8; 1; 4; 5; 8; 1; 6; 3];class3 = [x3 y3];figuregscatter(x1,y1,class1,'b')xlabel('Band 1'), ylabel('Band 2')title('Data of Each Class in Two-Dimensional Vector Space')hold ongscatter(x2,y2,class2,'r','x') hold ongscatter(x3,y3,class3,'g','o')legend('Class 1', 'Class 2', 'Class 3')
I am getting what I want on the plot but the legend says Class 1, Class 2, Class 3 but it shows the point structure from class 1 on each of the classes. What can I do on the legend to show the points of each class, respectively?
Best Answer