Plot Legend Command Does Not Work
이전 댓글 표시
Hello,
I am trying to put the legend for a 3D plot inside the plot (upper-right hand corner) but it refuses to do so even when using the proper command 'northeast'. My code:
figure
axis equal
xlabel('X (m)','FontSize',20,'Color','k')
ylabel('Y (m)','FontSize',20,'Color','k')
zlabel('Z (m)','FontSize',20,'Color','k')
title('Colored Trajectory Solutions','FontSize',25)
set(gca,'color','k');
hold on
leg1var = plot(nan,nan,'r');
leg2var = plot(nan,nan,'c');
legend([leg1var, leg2var],{['>|25|' char(176)],['<|25|' char(176)]},'Color','w','FontSize',15,'Location','northeast');
hold off
view(0,0)
zoom(4)
댓글 수: 5
Akira Agata
2019년 6월 11일
In my environment (MATLAB R2019b), your code works and returns the following figure. Please tell us more detail on the problem?

Jan
2019년 6월 11일
@Tom: Which Matlab version do you use? What do you observe?
Tom Keaton
2019년 6월 11일
편집: Tom Keaton
2019년 6월 11일
Jan
2019년 6월 11일
@Tom: "but that is also with the default window" - which default window? Is the shown picture a screenshot of the complete window or screen, or did you crop it?
You see, that the output of your Matlab differs from the standard output others get. So did you redefine some built-in Matlab functions or set some default properties of the figure in the root object?
"I want the legend to be bound within the 3D graph at all aspect ratios." - this is not really clear to me.
Tom Keaton
2019년 6월 12일
편집: Tom Keaton
2019년 6월 12일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


