UIAddLine - Interactively add horizontal/vertical line to existing plot. USAGE line = UIAddLine(dir,<options>) dir 'v' for vertical, 'h' for horizontal <options> options for function <a href="matlab:help plot">plot</a> NOTE Click where the line should appear, then hit 'ENTER'.
0001 function line = UIAddLine(dir,varargin) 0002 0003 %UIAddLine - Interactively add horizontal/vertical line to existing plot. 0004 % 0005 % USAGE 0006 % 0007 % line = UIAddLine(dir,<options>) 0008 % 0009 % dir 'v' for vertical, 'h' for horizontal 0010 % <options> options for function <a href="matlab:help plot">plot</a> 0011 % 0012 % NOTE 0013 % 0014 % Click where the line should appear, then hit 'ENTER'. 0015 0016 % Copyright (C) 2004-2011 by Michaƫl Zugaro 0017 % 0018 % This program is free software; you can redistribute it and/or modify 0019 % it under the terms of the GNU General Public License as published by 0020 % the Free Software Foundation; either version 3 of the License, or 0021 % (at your option) any later version. 0022 0023 % Check number of parameters 0024 if nargin < 1, 0025 error('Incorrect number of parameters (type ''help <a href="matlab:help UIAddLine">UIAddLine</a>'' for details).'); 0026 end 0027 0028 hold on; 0029 x = ginput; 0030 if strcmp(lower(dir),'v'), 0031 line = plot([x(end,1) x(end,1)],ylim,varargin{:}); 0032 else 0033 line = plot(xlim,[x(end,2) x(end,2)],varargin{:}); 0034 end