How do I move the legend on my plot?
Show older comments
I'd like to move the legend to the upper left corner of my plot. How do I do this?
M=linspace(0,0.1,500);
g=10;
for A=0.1:0.1:0.9
s=(A-0.5)*M*g-(A^2)/4;
theta=s./(2*M.*(A-0.5)^2+2*M+(A^2-A+1/3)/2);
N=((2*M-0.5*(A^2-A+1/6)).*theta-0.25*(A^2-A))/(A-0.5);
plot(M,N)
axis([0,0.1,-0.4,1])
hold all
end
legend('A=0.1','A=0.2','A=0.3','A=0.4','A=0.5','A=0.6','A=0.7','A=0.8','A=0.9')
Answers (1)
legend(...,'Location', 'location')
allows you to either specify the 'location' as one of a huge number of pre-defined positions e.g 'NorthWest', 'NorthWestOutside' or as a standard 1-by-4 position vector for precise manual positioning.
The pre-defined locations are included in a list on the help page for 'legend'
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!