Home > FMAToolbox > Plot > PlotHVLines.m

PlotHVLines

PURPOSE ^

PlotHVLines - Plot vertical (resp. horizontal) lines at listed x (resp. y).

SYNOPSIS ^

function p = PlotHVLines(positions,direction,varargin)

DESCRIPTION ^

PlotHVLines - Plot vertical (resp. horizontal) lines at listed x (resp. y).

  USAGE

    p = PlotHVLines(positions,direction,options)

    positions      list of abscissae/ordinates
    direction      optional direction: 'h' or 'v' (default = 'v')
    <options>      options for function <a href="matlab:help plot">plot</a>

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function p = PlotHVLines(positions,direction,varargin)
0002 
0003 %PlotHVLines - Plot vertical (resp. horizontal) lines at listed x (resp. y).
0004 %
0005 %  USAGE
0006 %
0007 %    p = PlotHVLines(positions,direction,options)
0008 %
0009 %    positions      list of abscissae/ordinates
0010 %    direction      optional direction: 'h' or 'v' (default = 'v')
0011 %    <options>      options for function <a href="matlab:help plot">plot</a>
0012 %
0013 
0014 % Copyright (C) 2008-2012 by Michaƫl Zugaro
0015 %
0016 % This program is free software; you can redistribute it and/or modify
0017 % it under the terms of the GNU General Public License as published by
0018 % the Free Software Foundation; either version 3 of the License, or
0019 % (at your option) any later version.
0020 
0021 if nargin < 1,
0022      error('Incorrect number of parameters (type ''help <a href="matlab:help PlotHVLines">PlotHVLines</a>'' for details).');
0023 end
0024 if nargin < 2,
0025     direction = 'v';
0026 else
0027     direction = lower(direction);
0028 end
0029 if min(size(positions)) > 2,
0030      error('List of abscissae/ordinates is not a vector (type ''help <a href="matlab:help PlotHVLines">PlotHVLines</a>'' for details).');
0031 else
0032     positions = positions(:);
0033 end
0034 
0035 if ~isastring(direction,'h','v'),
0036     varargin = {direction,varargin{:}};
0037     direction = 'v';
0038 end
0039 
0040 hold on;
0041 if strcmp(direction,'v'),
0042     yLim = ylim;
0043     for i = 1:size(positions,1),
0044         plot([positions(i,1) positions(i,1)],yLim,varargin{:});
0045     end
0046 else
0047     xLim = xlim;
0048     for i = 1:size(positions,1),
0049         plot(xLim,[positions(i,1) positions(i,1)],varargin{:});
0050     end
0051 end

Generated on Fri 16-Mar-2018 13:00:20 by m2html © 2005