1
votes

Hi and thanks for any help in advance, i am in the process of plotting a series of classified points in an axis. What i am trying to achieve is to have the plotted classes, which are in different colors dependant upon their class, is to have each of the classes plotted in each corner of the axis area.


This is my plot command

DATA = [X labels];
Z = (DATA(:,3)); % select all row three as classes
plot (DATA (Z == 1, 1), DATA (Z == 1, 2), 'k.', 'markersize', 5)
hold on
grid on
plot (DATA (Z == 2, 1), DATA (Z == 2, 2), 'rx', 'markersize', 5)
plot (DATA (Z == 3, 1), DATA (Z == 3, 2), 'g^', 'markersize', 5)
plot (DATA (Z == 4, 1), DATA (Z == 4, 2), 'b.', 'markersize', 5)

I need to plot each class in each corner of the axis

Thanks

Chris

1
Are you looking for the legend command? - kwatford
It is not clear to me what you're asking for. Do you want to plot the data so that [0,0] is, say, on the bottom left for Z==1, on the bottom right for Z==2, etc.? - Jonas

1 Answers

0
votes

Is this what you want to plot?

DATA = [rand(10,2),round(rand(10,1)*4)];% sample data

Z = DATA(:,3);

figure; hold on; axis tight; axis equal; grid on; box on;

p1=plot (DATA (Z == 1, 1), DATA (Z == 1, 2), 'k.', 'markersize', 5);

p2=plot (DATA (Z == 2, 1), DATA (Z == 2, 2), 'rx', 'markersize', 5);

p3=plot (DATA (Z == 3, 1), DATA (Z == 3, 2), 'g^', 'markersize', 5);

p4=plot (DATA (Z == 4, 1), DATA (Z == 4, 2), 'b.', 'markersize', 5);

legend([p1,p2,p3,p4],'Apple','Carrot','Orange','Banana')