Why isn't my legend matching my Graph
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Image Analyst
2017-12-3
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!