我需要你们的家伙帮助解决我面临的一个小问题。当我想使用bar函数描述f1和f2时,我需要在图的图例标签中排除f2注释对象,但是下面所写的集合语法似乎给出了所提及的错误。删除图例中的特定对象
的代码如下:
f1= bar([SN, SN, SN], [Class_Work, Final_Exam, Shift_Grade'-Grade], K, 'stacked');
f2= bar([SN(idx), SN(idx), SN(idx)], [Class_Work(idx), Final_Exam(idx), SG(idx)-Grade(idx)], K*dy/dx, 'stacked', 'LineWidth', 2.5);
set(f1,{'DisplayName'},{'Mid-Term','Final-Exam','Shift'}')
legend('location','NorthEast','Orientation','horizontal');
% in order to Exclude f2 indices from legend: (BUT SEEMS NOT WORKING based on error!)
set(get(get(f2,'Annotation'),'LegendInformation'),...
'IconDisplayStyle','off');
运行它给出了在命令窗口包括正确的数字此错误后,但与所有注释对象:
???错误使用==>得到
从单元转换为双重是不可能的。在==
错误>设置(获得(得到(F2, '注释'), 'LegendInformation'),...
的图,这是我需要的是:数据4,数据5,和DATA6图形对象在图例选项卡(与F2)不出现,绘图F2时。
我很欣赏你的帮助提前。
我意识到图例语法。我遇到的问题是,我有2套酒吧(f1和f2),因此有两个传说。因此,我需要使用下面的代码来强制f2图例的对象(例如,'data4','data5'和'data6')未被显示在图例栏中 – Hans 2013-02-14 10:08:10
问题出在:set(get (f2,'Annotation'),'LegendInformation'),... ??使用==>错误得到 从单元格转换为double是不可能的我怎样才能解决此行的语法问题?PLS帮助:( – Hans 2013-02-14 10:13:54
那么'get(h,'Annotation')'返回单元数组,所以你可以这样做:'annots = get(h,'Annotation');对于i = 1:length(annots); set(get(annots {i} ,'LegendInformation'),'IconDisplayStyle','off'); end;' – miy 2013-02-14 10:44:34