Effacer les filtres
Effacer les filtres

Why isn't my legend matching my Graph

1 vue (au cours des 30 derniers jours)
Bryan
Bryan le 3 Déc 2017
Below Is my For loop in my main script. The actions are using my main functions. For some reason my legend doesnt match my graph that I made. Attached is the picture of what I'm getting. Only the first entry in the legend is correct, and the rest is the wrong color or wrong type of label ( ex/ a dot instead of a line). Please Help. Thanks in advance.
for n = 1:7
[Xo, Yo, Zo, Imag, theta, phi, omgX, omgY, omgZ] = read_input('A.data',n);
[T, X, Y, Z, U, V, W] = basketball( Xo, Yo, Zo, Imag, theta, phi, omgX, omgY, omgZ);
hold on
plotStyle = {'b','k','r','g','m','c','w'};
plot3(X,Y,Z,plotStyle{n})
plot3(Xcourt,Ycourt,Zcourt,'.','color',[0.5 0.2 0.3]);
plot3(Xrim,Yrim,Zrim,'-','color',[.8 0 0.8],'LineWidth',2);
plot3(Xboard,Yboard,Zboard,'.','color',[0.8 0.7 0.7]);
legend('Shot #1', 'Shot #2', 'Shot #3','Shot #4', 'Shot #5','Shot #6','Shot #7')
box on; grid on; axis tight; axis equal;
xlabel('x (m)'); ylabel('y (m)'); zlabel('z (m)');
title('Basketball Court');
view(2);
set(gca,'FontSize',16);
end
  2 commentaires
Image Analyst
Image Analyst le 3 Déc 2017
You probably shouldn't have legend inside the loop because you'll have 7 curves the first time, 14 curves the second time, 21 curves the 3rd time, etc. but you're only doing 7 legends. Put the legend outside the loop.
Bryan
Bryan le 3 Déc 2017
I've tried that already, I still get the same results. The legend doesn't match the graph. I dont know why though

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by