home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts.fat / plot / mplot.m < prev    next >
Text File  |  1999-04-29  |  2KB  |  80 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. ## usage: mplot (x, y)
  21. ##        mplot (x1, y1, x2, y2, ...)
  22. ##        mplot (x, y, fmt)
  23. ##
  24. ## This is a modified version of plot() command to work with
  25. ## multiplt version of gnuplot to plot multiple plots per page.
  26. ## This plot version automatically updates the plot position to
  27. ## next plot position after making the plot in the given subplot
  28. ## position.
  29. ##
  30. ## See command plot() for the various options to this command
  31. ## as this is just mulitplot version of the same command.
  32.  
  33. ## Author: Vinayak Dutt <Dutt.Vinayak@mayo.EDU>
  34. ## Adapted-By: jwe
  35.  
  36. function mplot (...)
  37.  
  38.   if (! gnuplot_has_multiplt)
  39.     error ("mplot: gnuplot does not appear to support this feature");
  40.   endif
  41.  
  42.   ## global variables to keep track of multiplt options
  43.  
  44.   global __multiplt_mode__ = 0;
  45.   global __multiplt_xsize__;
  46.   global __multiplt_ysize__;
  47.   global __multiplt_xn__;
  48.   global __multiplt_yn__;
  49.   global __multiplt_xi__;
  50.   global __multiplt_yi__;
  51.  
  52.   gset nologscale;
  53.   gset nopolar;
  54.  
  55.   __plt__ ("plot", all_va_args);
  56.  
  57.   ## update the plot position
  58.  
  59.   if (__multiplt_mode__)
  60.  
  61.     if (__multiplt_xi__ < __multiplt_xn__)
  62.       __multiplt_xi__++;
  63.     else
  64.       __multiplt_xi__ = 1;
  65.       if (__multiplt_yi__ < __multiplt_yn__)
  66.     __multiplt_yi__++;
  67.       else
  68.     __multiplt_yi__ = 1;
  69.       endif
  70.     endif
  71.  
  72.     xo = (__multiplt_xi__ - 1.0) * __multiplt_xsize__;
  73.     yo = (__multiplt_yn__ - __multiplt_yi__) * __multiplt_ysize__;
  74.  
  75.     eval (sprintf ("gset origin %g, %g", xo, yo));
  76.  
  77.   endif
  78.  
  79. endfunction
  80.