home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts / plot / __plt__.m < prev    next >
Text File  |  1998-11-10  |  2KB  |  106 lines

  1. ## Copyright (C) 1996, 1997 John W. Eaton
  2. ##
  3. ## This file is part of Octave.
  4. ##
  5. ## Octave is free software; you can redistribute it and/or modify it
  6. ## under the terms of the GNU General Public License as published by
  7. ## the Free Software Foundation; either version 2, or (at your option)
  8. ## any later version.
  9. ##
  10. ## Octave is distributed in the hope that it will be useful, but
  11. ## WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. ## General Public License for more details.
  14. ##
  15. ## You should have received a copy of the GNU General Public License
  16. ## along with Octave; see the file COPYING.  If not, write to the Free
  17. ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  18. ## 02111-1307, USA.
  19.  
  20. ## Author: jwe
  21.  
  22. function __plt__ (caller, ...)
  23.  
  24.   if (nargin == 2)
  25.  
  26.     __plt1__ (va_arg (), "");
  27.  
  28.   elseif (nargin > 2)
  29.  
  30.     first_plot = 1;
  31.     hold_state = ishold ();
  32.  
  33.     unwind_protect
  34.  
  35.       x = va_arg ();
  36.       nargin = nargin - 2;
  37.       x_set = 1;
  38.       y_set = 0;
  39.  
  40.       ## Gather arguments, decode format, and plot lines.
  41.  
  42.       while (nargin-- > 0)
  43.  
  44.     fmt = "";
  45.     new = va_arg ();
  46.  
  47.     if (isstr (new))
  48.       if (! x_set)
  49.         error ("plot: no data to plot");
  50.       endif
  51.       fmt = __pltopt__ (caller, new);
  52.       if (! y_set)
  53.         __plt1__ (x, fmt);
  54.       else
  55.         __plt2__ (x, y, fmt);
  56.       endif
  57.       hold on;
  58.       x_set = 0;
  59.       y_set = 0;
  60.     elseif (x_set)
  61.       if (y_set)
  62.         __plt2__ (x, y, fmt);
  63.         hold on;
  64.         x = new;
  65.         y_set = 0;
  66.       else
  67.         y = new;
  68.         y_set = 1;
  69.       endif
  70.     else
  71.       x = new;
  72.       x_set = 1;
  73.     endif
  74.  
  75.       endwhile
  76.  
  77.       ## Handle last plot.
  78.  
  79.       if  (x_set)
  80.     if (y_set)
  81.       __plt2__ (x, y, fmt);
  82.     else
  83.       __plt1__ (x, fmt);
  84.     endif
  85.       endif
  86.  
  87.     unwind_protect_cleanup
  88.  
  89.       if (! hold_state)
  90.         hold off;
  91.       endif
  92.  
  93.     end_unwind_protect
  94.  
  95.   else
  96.  
  97.     msg = sprintf ("%s (x)\n", caller);
  98.     msg = sprintf ("%s       %s (x, y)\n", msg, caller);
  99.     msg = sprintf ("%s       %s (x2, y1, x2, y2)\n", msg, caller);
  100.     msg = sprintf ("%s       %s (x, y, fmt)", msg, caller);
  101.     usage (msg);
  102.  
  103.   endif
  104.  
  105. endfunction
  106.