Plot Legend Command Does Not Work

2 次查看(过去 30 天)
Tom Keaton
Tom Keaton 2019-6-10
编辑: Tom Keaton 2019-6-12
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 个评论
Jan
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
Tom Keaton 2019-6-12
编辑:Tom Keaton 2019-6-12
@Jan When I first input this code and the window for the 3D plot shows up, this is what it looks like:
It already looks as though the legend isn't inside the black box where the 3D plot is bound to. When I said bound, I mean I want the legend to be within the black region at all times. It doesn't look that way even with this small "default" window pop up. When I expand the window to full screen it looks like this:
Which is even worse because the legend is now completely to the upper right hand corner. Is there a way to specifically position the legend so that it is garunteed to always be within the plotting region at all times/aspect ratios? I also attached both photos so they are easier to view.

请先登录,再进行评论。

回答(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