How do I move the legend on my plot?

103 次查看(过去 30 天)
Josie
Josie 2014-8-1
编辑: Adam 2014-8-1
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')

回答(1 个)

Adam
Adam 2014-8-1
编辑:Adam 2014-8-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'

类别

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