MATLAB中legend总是出错,即使如下面的小程序都出错,请大神们帮忙解决一下,万分感谢。

小程序如下
x = -pi:pi/20:pi;
plot(x,cos(x),'-ro',x,sin(x),'-.b')
h = legend('cos_x','sin_x',2);
出错问题是
Attempt to call constructor text with incorrect letter case.

Error in scribe.legend/methods>strsize (line 979)
t=text('Parent',ax,...

Error in scribe.legend/methods>getsizeinfo (line 632)
strsizes(k,:) = strsize(h,ppos,fname,fsize,fangl,fwght,interp,str);

Error in scribe.legend/methods (line 19)
[varargout{1:nargout}] = feval(args{:});

Error in scribe.legend/methods>create_legend_items (line 1426)
s = methods(h,'getsizeinfo');

Error in scribe.legend/methods (line 17)
feval(args{:});

Error in scribe.legend (line 115)
methods(h,'create_legend_items',children);

Error in legend>make_legend (line 377)
lh=scribe.legend(ha,orient,location,position,children,listen,strings,propargs{:});

Error in legend (line 280)
[h,msg] = make_legend(ha,varargin(arg:end));
图像能显示,但是就是不显示图例。如果不加图例能正常运行,就是加了图例不行。

主要是图例的位置参数有错,程序可改为:
x = -pi:pi/20:pi;
plot(x,cos(x),'-ro',x,sin(x),'-.b')
h = legend('cos x','sin x','Location','NW');追问

大神,你能在帮我看看这个么,图例还是显示不出来
one_H_H_1=xlsread('p1_H_H_scan1.xls');
one_H_H_1=sortrows(one_H_H_1,1);
figure(1);
plot(one_H_H_1(:,1),one_H_H_1(:,2),'r-')
a=legend('the polarization of vertical direction',-1);

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答