view m-toolbox/classes/+utils/@plottools/legendAdd.m @ 19:69e3d49b4b0c
database-connection-manager
Update ltpda_uo.fromRepository
author
Daniele Nicolodi <nicolodi@science.unitn.it>
date
Mon, 05 Dec 2011 16:20:06 +0100 (2011-12-05)
parents
f0afece42f48
children
line source
+ − % LEGENDADD Add a string to the current legend.
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ − %
+ − % DESCRIPTION: LEGENDADD Add a string to the current legend.
+ − %
+ − % CALL: legendAdd(fig, 'string')
+ − % plot (curr_axes_handle, history, arg)
+ − %
+ − % INPUT: fig = figure handle (gcf, for example)
+ − % string = string to add
+ − %
+ − % VERSION: $Id: legendAdd.m,v 1.1 2008/08/05 17:51:32 ingo Exp $
+ − %
+ − % HISTORY: 26-01-07 M Hewitson
+ − % Creation
+ − %
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ −
+ − function legendAdd(varargin)
+ −
+ − if nargin ~=2
+ − error('usage: legendAdd(fig, ''strin'')');
+ − end
+ −
+ − fig = varargin{1};
+ − strin = varargin{2};
+ −
+ − if ~ischar(strin)
+ − error('arg 2 is not a string > usage: legendAdd(fig, ''strin'')');
+ − end
+ − % if ~isobject(fig)
+ − % error('arg 1 is not an object > usage: legendAdd(fig, ''strin'')');
+ − % end
+ −
+ − % get the current legend strings
+ −
+ −
+ − ch = get(gcf, 'Children');
+ − leg = [];
+ −
+ − for j=1:length(ch)
+ −
+ − tag = get(ch(j), 'Tag');
+ −
+ − if strcmp(tag, 'legend')
+ − leg = get(ch(j));
+ − end
+ −
+ − end
+ − str = [];
+ − % get(leg, 'XLabel')
+ − if ~isempty(leg)
+ − for j=length(leg.Children):-1:1
+ −
+ − ch = leg.Children(j);
+ −
+ − tag = get(ch, 'Tag');
+ −
+ − if ~strcmp(tag, '')
+ −
+ − str = strvcat(str, tag);
+ − end
+ − end
+ − end
+ −
+ − str = strvcat(str, strin);
+ −
+ − legend(str);
+ −
+ − end
+ −