home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts.fat / plot / multiplt.m < prev    next >
Text File  |  1999-04-29  |  3KB  |  108 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: multiplt (xn, yn)
  21. ##
  22. ## Sets and resets multiplt mode
  23. ##
  24. ## If multiplt(0,0) then it will close multiplt mode and and if
  25. ## arguments are non-zero, then it will set up multiplt mode with
  26. ## xn,yn subplots along x and y axes.
  27. ##
  28. ## NOTE: this will work only with gnuplot installed with
  29. ##       multiplt patch
  30.  
  31. ## Author: Vinayak Dutt, Dutt.Vinayak@mayo.EDU
  32. ## Created: 3 July 95
  33. ## Adapted-By: jwe
  34.  
  35. function multiplt (xn, yn)
  36.  
  37.   if (! gnuplot_has_multiplt)
  38.     error ("multiplt: gnuplot does not appear to support this feature");
  39.   endif
  40.  
  41.   ## global variables to keep track of multiplt options
  42.  
  43.   global __multiplt_mode__ = 0;
  44.   global __multiplt_xsize__;
  45.   global __multiplt_ysize__;
  46.   global __multiplt_xn__;
  47.   global __multiplt_yn__;
  48.   global __multiplt_xi__;
  49.   global __multiplt_yi__;
  50.  
  51.   if (nargin != 2)
  52.     usage ("multiplt (xn, yn)");
  53.   endif
  54.  
  55.   if (! (is_scal (xn) && is_scal (yn)))
  56.     error ("multiplt: xn and yn have to be scalars");
  57.   endif
  58.  
  59.   xn = round (xn);
  60.   yn = round (yn);
  61.  
  62.   if (xn == 0 && yn == 0)
  63.  
  64.     oneplot ();
  65.  
  66.     ## XXX FIXME XXX -- do we really need to reset these here?
  67.  
  68.     __multiplt_xsize__ = 1;
  69.     __multiplt_ysize__ = 1;
  70.     __multiplt_xn__ = 1;
  71.     __multiplt_yn__ = 1;
  72.     __multiplt_xi__ = 1;
  73.     __multiplt_yi__ = 1;
  74.  
  75.   else
  76.  
  77.     if (xn < 1 || yn < 1)
  78.       error ("multiplt: xn and yn have to be positive integers");
  79.     endif
  80.  
  81.     gset multiplt;
  82.  
  83.     xsize = 1.0 ./ xn;
  84.     ysize = 1.0 ./ yn;
  85.  
  86.     eval (sprintf ("gset size %g, %g", xsize, ysize));
  87.  
  88.     xo = 0.0;
  89.     yo = (yn - 1.0)*ysize;
  90.  
  91.     eval (sprintf ("gset origin %g, %g", xo, yo));
  92.  
  93.     __multiplt_mode__ = 1;
  94.     __multiplt_xsize__ = xsize;
  95.     __multiplt_ysize__ = ysize;
  96.     __multiplt_xn__ = xn;
  97.     __multiplt_yn__ = yn;
  98.     __multiplt_xi__ = 1;
  99.     __multiplt_yi__ = 1;
  100.  
  101.     gnuplot_command_replot = "cle;rep";
  102.  
  103.     clearplot;
  104.  
  105.   endif
  106.  
  107. endfunction
  108.