www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@xregGui/setLegendData.m
function setLegendData(L, Name) %SETLEGENDDATA Set legend information for a line. % % SETLEGENDDATA(L, NAME) sets a line to be legended and use the given % NAME as a string in the legend when these features are available. % % SETLEGENDDATA(L, false) disables the legending of the line object if % this is available. % % This helper function is intended to allow R2007b MBC code to assume % that the "DisplayName" and "Annotation" properties will exist in lines % when it is shipped, but not error while they are not. % Copyright 2007 The MathWorks, Inc. if ischar(Name) DoLegend = 'on'; Name = repmat({Name}, size(L)); elseif iscell(Name) DoLegend = 'on'; elseif islogical(Name) && ~Name DoLegend = 'off'; Name = repmat({''}, size(L)); else error(message('mbc:xregGui:setLegendData:InvalidArgument')); end for n = 1:numel(L) if isprop(L(n), 'DisplayName') set(L(n), 'DisplayName', Name{n}); end if isprop(L(n), 'Annotation') A = get(L(n), 'Annotation'); A.LegendInformation.IconDisplayStyle = DoLegend; end end