home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts.fat / plot / axis.m < prev    next >
Text File  |  1999-04-29  |  2KB  |  75 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: axis ()
  21. ##        axis ([xmin, xmax])
  22. ##        axis ([xmin, xmax, ymin, ymax])
  23. ##        axis ([xmin, xmax, ymin, ymax, zmin, zmax])
  24. ##
  25. ## Sets the axis limits.
  26. ##
  27. ## With no arguments, turns autoscaling on.
  28. ##
  29. ## If your plot is already drawn, then you need to REPLOT before
  30. ## the new axis limits will take effect.
  31.  
  32. ## Author: jwe
  33.  
  34. function curr_axis = axis (ax)
  35.  
  36.   ## This may not be correct if someone has used the gnuplot interface
  37.   ## directly...
  38.  
  39.   global __current_axis__ = [-10, 10, -10, 10];
  40.  
  41.   if (nargin > 1)
  42.     usage ("axis ([xmin, xmax, ymin, ymax, zmin, zmax])");
  43.   endif
  44.  
  45.   if (nargin == 0)
  46.     gset autoscale;
  47.     curr_axis = __current_axis__;
  48.   elseif (is_vec (ax))
  49.  
  50.     len = length (ax);
  51.  
  52.     if (len != 2 && len != 4 && len != 6)
  53.       error ("axis: expecting vector with 2, 4, or 6 elements");
  54.     endif
  55.  
  56.     __current_axis__ = reshape (ax, 1, len);
  57.  
  58.     if (len > 1)
  59.       eval (sprintf ("gset xrange [%g:%g];", ax (1), ax (2)));
  60.     endif
  61.  
  62.     if (len > 3)
  63.       eval (sprintf ("gset yrange [%g:%g];", ax (3), ax (4)));
  64.     endif
  65.  
  66.     if (len > 5)
  67.       eval (sprintf ("gset zrange [%g:%g];", ax (5), ax (6)));
  68.     endif
  69.  
  70.   else
  71.     error ("axis: expecting no args, or a vector with 2, 4, or 6 elements");
  72.   endif
  73.  
  74. endfunction
  75.