Mercurial > hg > octave-lyh
annotate scripts/plot/saveas.m @ 11341:3c7ba1e3dc21
Add missing option slice for pie and pie3
author | Kai Habel <kai.habel@gmx.de> |
---|---|
date | Fri, 10 Dec 2010 19:53:06 +0100 |
parents | 31f8534eb055 |
children | c776f063fefe |
rev | line source |
---|---|
11253 | 1 ## Copyright (C) 2010 Kai Habel |
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 -*- | |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
20 ## @deftypefn {Function File} {} saveas (@var{h}, @var{filename}) |
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
21 ## @deftypefnx {Function File} {} saveas (@var{h}, @var{filename}, @var{ext}) |
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
22 ## Save the graphic object @var{h} to file @var{filename} in graphic |
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
23 ## format @var{ext}. |
11253 | 24 ## |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
25 ## @var{ext} should be one of the following formats: |
11253 | 26 ## |
27 ## @table @code | |
28 ## @item ps | |
29 ## Postscript | |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
30 ## |
11253 | 31 ## @item eps |
32 ## Encapsulated Postscript | |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
33 ## |
11253 | 34 ## @item jpg |
35 ## JPEG Image | |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
36 ## |
11253 | 37 ## @item png |
38 ## PNG Image | |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
39 ## |
11253 | 40 ## @item emf |
41 ## Enhanced Meta File | |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
42 ## |
11253 | 43 ## @item pdf |
44 ## Portable Document Format | |
45 ## @end table | |
46 ## | |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
47 ## All device formats specified in @code{print} may also be used. If |
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
48 ## @var{ext} is omitted it is extracted from @var{filename}. The default |
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
49 ## value is pdf. |
11253 | 50 ## |
51 ## @example | |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
52 ## @group |
11253 | 53 ## figure (1); |
54 ## clf (); | |
55 ## surf (peaks); | |
56 ## saveas(1, "figure1.png"); | |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
57 ## @end group |
11253 | 58 ## @end example |
59 ## | |
60 ## @seealso{print} | |
61 ## @end deftypefn | |
62 | |
63 ## Author: Kai Habel | |
64 | |
65 function saveas (h, fname, fext = "pdf") | |
66 | |
67 if ((nargin != 2) && (nargin != 3)) | |
68 print_usage (); | |
69 endif | |
70 | |
71 if (ishandle (h)) | |
72 if (isfigure (h)) | |
73 fig = h; | |
74 else | |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
75 fig = ancestor (h, "figure"); |
11253 | 76 endif |
77 else | |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
78 error ("saveas: first argument H must be a graphics handle"); |
11253 | 79 endif |
80 | |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
81 if (!ischar (fname)) |
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
82 error ("saveas: FILENAME must be a string"); |
11253 | 83 endif |
84 | |
85 if (nargin == 2) | |
86 [~, ~, ext] = fileparts (fname); | |
87 if (!isempty (ext)) | |
88 fext = ext(2:end); | |
89 endif | |
90 endif | |
91 | |
92 if (nargin == 3) | |
93 if (!ischar (fname)) | |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
94 error ("saveas: EXT must be a string"); |
11253 | 95 endif |
96 | |
97 [~, ~, ext] = fileparts (fname); | |
98 | |
99 if (isempty (ext)) | |
100 fname = strcat (fname, ".", fext); | |
101 endif | |
102 endif | |
103 | |
104 prt_opt = strcat ("-d", tolower (fext)); | |
105 | |
11254
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
106 print (fname, prt_opt); |
31f8534eb055
Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents:
11253
diff
changeset
|
107 |
11253 | 108 endfunction |