home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts.fat / plot / subwindw.m < prev    next >
Text File  |  1999-04-29  |  2KB  |  84 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: subwindw (xn, yn)
  21. ##
  22. ## NOTE: this will work only with gnuplot installed with
  23. ##       multiplt patch
  24. ##
  25. ## Sets subwindw position in multiplt mode for next plot. The
  26. ## multiplt mode has to be previously initialized using multiplt()
  27. ## command, else this command just becomes an aliad to multiplt()
  28.  
  29. ## Author: Vinayak Dutt <Dutt.Vinayak@mayo.EDU>
  30. ## Created: 3 July 95
  31. ## Adapted-By: jwe
  32.  
  33. function subwindw (xn, yn)
  34.  
  35.   if (! gnuplot_has_multiplt)
  36.     error ("subwindw: gnuplot does not appear to support this feature");
  37.   endif
  38.  
  39.   ## global variables to keep track of multiplt options
  40.  
  41.   global __multiplt_mode__ = 0;
  42.   global __multiplt_xsize__;
  43.   global __multiplt_ysize__;
  44.   global __multiplt_xn__;
  45.   global __multiplt_yn__;
  46.  
  47.   ## check calling argument count
  48.  
  49.   if (nargin != 2)
  50.     usage ("subwindw (xn, yn)");
  51.   endif
  52.  
  53.   ## check for scalar inputs
  54.  
  55.   if (! (is_scal (xn) && is_scal (yn)))
  56.     error ("subwindw: xn and yn have to be scalars");
  57.   endif
  58.  
  59.   xn = round (xn);
  60.   yn = round (yn);
  61.  
  62.   ## switch to multiplt mode if not already in, and use the args as the
  63.   ## args to multiplt()
  64.  
  65.   if (! __multiplt_mode__)
  66.     multiplt (xn, yn);
  67.     return;
  68.   endif
  69.  
  70.   ## get the sub plot location
  71.  
  72.   if (xn < 1 || xn > __multiplt_xn__ || yn < 1 || yn > __multiplt_yn__)
  73.     error ("subwindw: incorrect xn and yn");
  74.   endif
  75.  
  76.   xo = (xn - 1.0) * __multiplt_xsize__;
  77.   yo = (__multiplt_yn__ - yn) * __multiplt_ysize__;
  78.  
  79.   eval (sprintf ("gset origin %g, %g", xo, yo));
  80.  
  81.   clearplot;
  82.  
  83. endfunction
  84.