MATLAB: Legend Position on a plot

legendplotting

I'm trying to manually set the position of my legend in a plot that I am doing because the default locations do not work for me. The relevant portion of the code is:
h=legend('Nmax=8','Nmax=10','Nmax=12','Nmax=14'); set(h, 'Box', 'off') set(h,'fontsize',12,'fontweight','b') set(gcf,'Units','normalized') rect=[0.25, 0.25, .25, .25]; set(h,'Location','rect') print -depsc2 Li7.Nm14.EnergySpec.eps
I keep getting the following error message: ??? Error using ==> set The 'rect' enumerated value is invalid.
Error in ==> energySpecPlotLi7 at 71 set(h,'Location','rect')
I have tried several different values for the position vector, but I still can't seem to get it to work. Any idea what I am doing wrong?
Thanks in advance!

Best Answer

"set(h,'Location','rect')" uses the string 'rect', but you want to use the variable.
[EDITED]: The 'Location' property uses the strings 'southeast', 'northeast', 'best' etc. as argument. If you want to set the position to a rectangle, use the 'Position' property:
rect = [0.25, 0.25, .25, .25];
set(h, 'Position', rect)