How do I fix my legend?
Show older comments
Hello, I am creating a graph with mutiple for loops to obtain data, the problem at the moment is when I try to creat a legend corresponding to each specific value the it is only seeing the first for loop.
figure, hold on
for i=1:size(AB,1)
a1 = VAB(:,1)'*AB(i,:)';
b1 = VAB(:,2)'*AB(i,:)';
plot(a1,b1,'ko','LineWidth',3)
end
for i=1:size(CD,1)
c1 = VCD(:,1)'*CD(i,:)';
d1 = VCD(:,2)'*CD(i,:)';
plot(c1,d1,'bo','LineWidth',3)
end
for i=1:size(EF,1)
e1 = VEF(:,1)'*EF(i,:)';
f1 = VEF(:,2)'*EF(i,:)';
plot(e1,f1,'go','LineWidth',3)
end
for i=1:size(GH,1)
g1 = VGH(:,1)'*GH(i,:)';
h1 = VGH(:,2)'*GH(i,:)';
plot(g1,h1,'mo','LineWidth',3)
end
xlabel('PC1'),ylabel('PC2')
grid on, set(gca,'FontSize',15)
axis ([-1 1 -.1 .1])
legend('CAP','Capsiate','RTX','CPZ')

Accepted Answer
More Answers (0)
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!