IceMan30
Military
- Jan 19, 2011
- 32
Really simple question...
What's the trick to adding a legend to a matlab plot? I'm a pretty experienced Matlab user, just shaking the rust off after a couple years of little use. To cite the example in a Matlab manual (version 7, from early 2009 I think):
>> x = 0
i/200:2*pi;
>> y = sin(x);
>> y2 = sin(x-.25);
>> y3 = sin(x-.5);
>> plot(x,y,x,y2,x,y3)
>> legend('sin(x)','sin(x-.25)','sin(x-.50)')
When I plot this, the figure comes up fine, but I get the following errors in regards to the legend:
************************************************
??? Error using ==> hgconvertunits
Invalid object handle.
Error in ==> legend>make_legend at 386
lh=scribe.legend(ha,orient,location,position,children,listen,strings,propargs{:});
Error in ==> legend at 285
[h,msg] = make_legend(ha,varargin(arg:end));
*************************************************
I've yet to step through the "legend" code, but really, for a simple figure legend, this seems a bit ridiculous.
Any thoughts? What the crap am I doing wrong??
Thanks in advance!
What's the trick to adding a legend to a matlab plot? I'm a pretty experienced Matlab user, just shaking the rust off after a couple years of little use. To cite the example in a Matlab manual (version 7, from early 2009 I think):
>> x = 0
>> y = sin(x);
>> y2 = sin(x-.25);
>> y3 = sin(x-.5);
>> plot(x,y,x,y2,x,y3)
>> legend('sin(x)','sin(x-.25)','sin(x-.50)')
When I plot this, the figure comes up fine, but I get the following errors in regards to the legend:
************************************************
??? Error using ==> hgconvertunits
Invalid object handle.
Error in ==> legend>make_legend at 386
lh=scribe.legend(ha,orient,location,position,children,listen,strings,propargs{:});
Error in ==> legend at 285
[h,msg] = make_legend(ha,varargin(arg:end));
*************************************************
I've yet to step through the "legend" code, but really, for a simple figure legend, this seems a bit ridiculous.
Any thoughts? What the crap am I doing wrong??
Thanks in advance!