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