]> Creatis software - CreaPhase.git/blob - octave_packages/m/plot/title.m
update packages
[CreaPhase.git] / octave_packages / m / plot / title.m
1 ## Copyright (C) 1993-2012 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 3 of the License, or (at
8 ## your option) 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, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn  {Function File} {} title (@var{string})
21 ## @deftypefnx {Function File} {} title (@var{string}, @var{p1}, @var{v1}, @dots{})
22 ## @deftypefnx {Function File} {} title (@var{h}, @dots{})
23 ## @deftypefnx {Function File} {@var{h} =} title (@dots{})
24 ## Create a title object for a plot.
25 ##
26 ## The optional return value @var{h} is a graphics handle to the created object.
27 ## @end deftypefn
28
29 ## Author: jwe
30
31 function retval = title (varargin)
32
33   [h, varargin, nargin] = __plt_get_axis_arg__ ("title", varargin{:});
34
35   if (rem (nargin, 2) != 1)
36     print_usage ();
37   endif
38
39   tmp = __axis_label__ (h, "title", varargin{:});
40
41   if (nargout > 0)
42     retval = tmp;
43   endif
44
45 endfunction
46
47
48 %!demo
49 %! clf ();
50 %! ax = axes();
51 %! xl = get (ax,"title");
52 %! title ("Testing title");
53 %! assert (get (xl,"string"), "Testing title");
54
55 %!demo
56 %! clf ();
57 %! plot3 ([0,1], [0,1], [0,1]);
58 %! xl = get(gca (), "title");
59 %! title ("Testing title");
60 %! assert (get (xl,"string"),"Testing title");
61
62 %!test
63 %! hf = figure ("visible", "off");
64 %! unwind_protect
65 %!   ax = axes();
66 %!   xl = get (ax,"title");
67 %!   title ("Testing title");
68 %!   assert (get (xl,"string"), "Testing title");
69 %! unwind_protect_cleanup
70 %!   close (hf);
71 %! end_unwind_protect
72
73 %!test
74 %! hf = figure ("visible", "off");
75 %! unwind_protect
76 %!   plot3 ([0,1], [0,1], [0,1]);
77 %!   xl = get (gca (), "title");
78 %!   title("Testing title");
79 %!   assert (get (xl,"string"), "Testing title");
80 %! unwind_protect_cleanup
81 %!   close (hf);
82 %! end_unwind_protect
83