필터 지우기
필터 지우기

Why isn't my legend matching my Graph

조회 수: 1 (최근 30일)
Bryan
Bryan 2017년 12월 3일
편집: Walter Roberson 2017년 12월 3일
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
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.
Bryan
Bryan 2017년 12월 3일
I've tried that already, I still get the same results. The legend doesn't match the graph. I dont know why though

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by