File: Printing-and-Saving-Plots.html

package info (click to toggle)
octave 3.8.2-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 84,396 kB
  • ctags: 45,547
  • sloc: cpp: 293,356; ansic: 42,041; fortran: 23,669; sh: 13,629; objc: 7,890; yacc: 7,093; lex: 3,442; java: 2,125; makefile: 1,589; perl: 1,009; awk: 974; xml: 34
file content (472 lines) | stat: -rw-r--r-- 16,857 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GNU Octave: Printing and Saving Plots</title>

<meta name="description" content="GNU Octave: Printing and Saving Plots">
<meta name="keywords" content="GNU Octave: Printing and Saving Plots">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="High_002dLevel-Plotting.html#High_002dLevel-Plotting" rel="up" title="High-Level Plotting">
<link href="Interacting-with-Plots.html#Interacting-with-Plots" rel="next" title="Interacting with Plots">
<link href="Use-of-the-interpreter-Property.html#Use-of-the-interpreter-Property" rel="prev" title="Use of the interpreter Property">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Printing-and-Saving-Plots"></a>
<div class="header">
<p>
Next: <a href="Interacting-with-Plots.html#Interacting-with-Plots" accesskey="n" rel="next">Interacting with Plots</a>, Previous: <a href="Use-of-the-interpreter-Property.html#Use-of-the-interpreter-Property" accesskey="p" rel="prev">Use of the <code>interpreter</code> Property</a>, Up: <a href="High_002dLevel-Plotting.html#High_002dLevel-Plotting" accesskey="u" rel="up">High-Level Plotting</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Printing-and-Saving-Plots-1"></a>
<h4 class="subsection">15.2.8 Printing and Saving Plots</h4>
<a name="index-plotting_002c-saving-and-printing-plots"></a>
<a name="index-printing-plots"></a>
<a name="index-saving-plots"></a>

<p>The <code>print</code> command allows you to send plots to you printer and
to save plots in a variety of formats.  For example,
</p>
<div class="example">
<pre class="example">print -dpsc
</pre></div>

<p>prints the current figure to a color PostScript printer.  And,
</p>
<div class="example">
<pre class="example">print -deps foo.eps
</pre></div>

<p>saves the current figure to an encapsulated PostScript file called
<samp>foo.eps</samp>.
</p>
<a name="XREFprint"></a><dl>
<dt><a name="index-print"></a>Function File: <em></em> <strong>print</strong> <em>()</em></dt>
<dt><a name="index-print-1"></a>Function File: <em></em> <strong>print</strong> <em>(<var>options</var>)</em></dt>
<dt><a name="index-print-2"></a>Function File: <em></em> <strong>print</strong> <em>(<var>filename</var>, <var>options</var>)</em></dt>
<dt><a name="index-print-3"></a>Function File: <em></em> <strong>print</strong> <em>(<var>h</var>, <var>filename</var>, <var>options</var>)</em></dt>
<dd><p>Print a plot, or save it to a file.
</p>
<p>Both output formatted for printing (PDF and PostScript), and many bitmapped
and vector image formats are supported.
</p>
<p><var>filename</var> defines the name of the output file.  If the
file name has no suffix, one is inferred from the specified
device and appended to the file name.  If no filename is
specified, the output is sent to the printer.
</p>
<p><var>h</var> specifies the handle of the figure to print.  If no handle is
specified the current figure is used.
</p>
<p>For output to a printer, PostScript file, or PDF file,
the paper size is specified by the figure&rsquo;s <code>papersize</code>
property.  The location and size of the image on the page are
specified by the figure&rsquo;s <code>paperposition</code> property.  The
orientation of the page is specified by the figure&rsquo;s
<code>paperorientation</code> property.
</p>
<p>The width and height of images are specified by the figure&rsquo;s
<code>paperpositon(3:4)</code> property values.
</p>
<p>The <code>print</code> command supports many <var>options</var>:
</p>
<dl compact="compact">
<dt><code>-f<var>h</var></code></dt>
<dd><p>Specify the handle, <var>h</var>, of the figure to be printed.  The
default is the current figure.
</p>
</dd>
<dt><code>-P<var>printer</var></code></dt>
<dd><p>Set the <var>printer</var> name to which the plot is sent if no
<var>filename</var> is specified.
</p>
</dd>
<dt><code>-G<var>ghostscript_command</var></code></dt>
<dd><p>Specify the command for calling Ghostscript.  For Unix and Windows
the defaults are <code>&quot;gs&quot;</code> and <code>&quot;gswin32c&quot;</code>, respectively.
</p>
</dd>
<dt><code>-color</code></dt>
<dt><code>-mono</code></dt>
<dd><p>Color or monochrome output.
</p>
</dd>
<dt><code>-solid</code></dt>
<dt><code>-dashed</code></dt>
<dd><p>Force all lines to be solid or dashed, respectively.
</p>
</dd>
<dt><code>-portrait</code></dt>
<dt><code>-landscape</code></dt>
<dd><p>Specify the orientation of the plot for printed output.  For
non-printed output the aspect ratio of the output corresponds to
the plot area defined by the <code>&quot;paperposition&quot;</code> property in the
orientation specified.  This option is equivalent to changing
the figure&rsquo;s <code>&quot;paperorientation&quot;</code> property.
</p>
</dd>
<dt><code>-TextAlphaBits=<var>n</var></code></dt>
<dt><code>-GraphicsAlphaBits=<var>n</var></code></dt>
<dd><p>Octave is able to produce output for various printers, bitmaps, and
vector formats by using Ghostscript.
For bitmap and printer output anti-aliasing is applied using
Ghostscript&rsquo;s TextAlphaBits and GraphicsAlphaBits options.
The default number of bits for each is 4.
Allowed values for <var>N</var> are 1, 2, or 4.
</p>
</dd>
<dt><code>-d<var>device</var></code></dt>
<dd><p>The available output format is specified by the option <var>device</var>,
and is one of:
</p>
<dl compact="compact">
<dt><code>ps</code></dt>
<dt><code>ps2</code></dt>
<dt><code>psc</code></dt>
<dt><code>psc2</code></dt>
<dd><p>PostScript (level 1 and 2, mono and color).  The FLTK graphics
toolkit generates PostScript level 3.0.
</p>
</dd>
<dt><code>eps</code></dt>
<dt><code>eps2</code></dt>
<dt><code>epsc</code></dt>
<dt><code>epsc2</code></dt>
<dd><p>Encapsulated PostScript (level 1 and 2, mono and color).  The FLTK
graphic toolkit generates PostScript level 3.0.
</p>
</dd>
<dt><code>tex</code></dt>
<dt><code>epslatex</code></dt>
<dt><code>epslatexstandalone</code></dt>
<dt><code>pstex</code></dt>
<dt><code>pslatex</code></dt>
<dt><code>pdflatex</code></dt>
<dd><p>Generate a LaTeX (or TeX) file for labels and eps/ps/pdf
for graphics.  The file produced by <code>epslatexstandalone</code> can be
processed directly by LaTeX.  The other formats are intended to
be included in a LaTeX (or TeX) document.  The <code>tex</code> device
is the same as the <code>epslatex</code> device.  The <code>pdflatex</code> device
is only available for the FLTK graphics toolkit.
</p>
</dd>
<dt><code>tikz</code></dt>
<dd><p>Generate a LaTeX file using PGF/TikZ.  For the FLTK toolkit
the result is PGF.
</p>
</dd>
<dt><code>ill</code></dt>
<dt><code>aifm</code></dt>
<dd><p>Adobe Illustrator (Obsolete for Gnuplot versions &gt; 4.2)
</p>
</dd>
<dt><code>cdr</code></dt>
<dt><code>corel</code></dt>
<dd><p>CorelDraw
</p>
</dd>
<dt><code>dxf</code></dt>
<dd><p>AutoCAD
</p>
</dd>
<dt><code>emf</code></dt>
<dt><code>meta</code></dt>
<dd><p>Microsoft Enhanced Metafile
</p>
</dd>
<dt><code>fig</code></dt>
<dd><p>XFig.  For the Gnuplot graphics toolkit, the additional options
<samp>-textspecial</samp> or <samp>-textnormal</samp> can be used to control
whether the special flag should be set for the text in
the figure.  (default is <samp>-textnormal</samp>)
</p>
</dd>
<dt><code>hpgl</code></dt>
<dd><p>HP plotter language
</p>
</dd>
<dt><code>mf</code></dt>
<dd><p>Metafont
</p>
</dd>
<dt><code>png</code></dt>
<dd><p>Portable network graphics
</p>
</dd>
<dt><code>jpg</code></dt>
<dt><code>jpeg</code></dt>
<dd><p>JPEG image
</p>
</dd>
<dt><code>gif</code></dt>
<dd><p>GIF image (only available for the Gnuplot graphics toolkit)
</p>
</dd>
<dt><code>pbm</code></dt>
<dd><p>PBMplus
</p>
</dd>
<dt><code>svg</code></dt>
<dd><p>Scalable vector graphics
</p>
</dd>
<dt><code>pdf</code></dt>
<dd><p>Portable document format
</p></dd>
</dl>

<p>If the device is omitted, it is inferred from the file extension,
or if there is no filename it is sent to the printer as PostScript.
</p>
</dd>
<dt><code>-d<var>ghostscript_device</var></code></dt>
<dd><p>Additional devices are supported by Ghostscript.
Some examples are;
</p>
<dl compact="compact">
<dt><code>ljet2p</code></dt>
<dd><p>HP LaserJet IIP
</p>
</dd>
<dt><code>ljet3</code></dt>
<dd><p>HP LaserJet III
</p>
</dd>
<dt><code>deskjet</code></dt>
<dd><p>HP DeskJet and DeskJet Plus
</p>
</dd>
<dt><code>cdj550</code></dt>
<dd><p>HP DeskJet 550C
</p>
</dd>
<dt><code>paintjet</code></dt>
<dd><p>HP PointJet
</p>
</dd>
<dt><code>pcx24b</code></dt>
<dd><p>24-bit color PCX file format
</p>
</dd>
<dt><code>ppm</code></dt>
<dd><p>Portable Pixel Map file format
</p>
</dd>
<dt><code>pdfwrite</code></dt>
<dd><p>Produces pdf output from eps
</p></dd>
</dl>

<p>For a complete list, type <code>system (&quot;gs -h&quot;)</code> to see what formats
and devices are available.
</p>
<p>When Ghostscript output is sent to a printer the size is determined
by the figure&rsquo;s <code>&quot;papersize&quot;</code> property.  When the output
is sent to a file the size is determined by the plot box defined by
the figure&rsquo;s <code>&quot;paperposition&quot;</code> property.
</p>
</dd>
<dt><code>-append</code></dt>
<dd><p>Append PostScript or PDF output to a pre-existing file of the same type.
</p>
</dd>
<dt><code>-r<var>NUM</var></code></dt>
<dd><p>Resolution of bitmaps in pixels per inch.  For both metafiles and
SVG the default is the screen resolution; for other formats it is 150 dpi.
To specify screen resolution, use <code>&quot;-r0&quot;</code>.
</p>
</dd>
<dt><code>-loose</code></dt>
<dt><code>-tight</code></dt>
<dd><p>Force a tight or loose bounding box for eps files.  The default is loose.
</p>
</dd>
<dt><code>-<var>preview</var></code></dt>
<dd><p>Add a preview to eps files.  Supported formats are:
</p>
<dl compact="compact">
<dt><code>-interchange</code></dt>
<dd><p>Provide an interchange preview.
</p>
</dd>
<dt><code>-metalfile</code></dt>
<dd><p>Provide a metafile preview.
</p>
</dd>
<dt><code>-pict</code></dt>
<dd><p>Provide pict preview.
</p>
</dd>
<dt><code>-tiff</code></dt>
<dd><p>Provide a tiff preview.
</p></dd>
</dl>

</dd>
<dt><code>-S<var>xsize</var>,<var>ysize</var></code></dt>
<dd><p>Plot size in pixels for EMF, GIF, JPEG, PBM, PNG, and SVG.  For
PS, EPS, PDF, and other vector formats the plot size is in points.
This option is equivalent to changing the size of the plot box
associated with the <code>&quot;paperposition&quot;</code> property.  When using the
command form of the print function you must quote the
<var>xsize</var>,<var>ysize</var> option.  For example, by writing <span class="nolinebreak">&quot;-S640,480&quot;</span><!-- /@w -->.
</p>
</dd>
<dt><code>-F<var>fontname</var></code></dt>
<dt><code>-F<var>fontname</var>:<var>size</var></code></dt>
<dt><code>-F:<var>size</var></code></dt>
<dd><p>Use <var>fontname</var> and/or <var>fontsize</var> for all text.
<var>fontname</var> is ignored for some devices: dxf, fig, hpgl, etc.
</p></dd>
</dl>

<p>The filename and options can be given in any order.
</p>
<p>Example: Print to a file using the svg device.
</p>
<div class="example">
<pre class="example">figure (1);
clf ();
surf (peaks);
print -dsvg figure1.svg
</pre></div>

<p>Example: Print to an HP DeskJet 550C.
</p>
<div class="example">
<pre class="example">clf ();
surf (peaks);
print -dcdj550
</pre></div>


<p><strong>See also:</strong> <a href="#XREFsaveas">saveas</a>, <a href="#XREForient">orient</a>, <a href="Multiple-Plot-Windows.html#XREFfigure">figure</a>.
</p></dd></dl>


<a name="XREFsaveas"></a><dl>
<dt><a name="index-saveas"></a>Function File: <em></em> <strong>saveas</strong> <em>(<var>h</var>, <var>filename</var>)</em></dt>
<dt><a name="index-saveas-1"></a>Function File: <em></em> <strong>saveas</strong> <em>(<var>h</var>, <var>filename</var>, <var>fmt</var>)</em></dt>
<dd><p>Save graphic object <var>h</var> to the file <var>filename</var> in graphic
format <var>fmt</var>.
</p>
<p><var>fmt</var> should be one of the following formats:
</p>
<dl compact="compact">
<dt><code>ps</code></dt>
<dd><p>PostScript
</p>
</dd>
<dt><code>eps</code></dt>
<dd><p>Encapsulated PostScript
</p>
</dd>
<dt><code>jpg</code></dt>
<dd><p>JPEG Image
</p>
</dd>
<dt><code>png</code></dt>
<dd><p>PNG Image
</p>
</dd>
<dt><code>emf</code></dt>
<dd><p>Enhanced Meta File
</p>
</dd>
<dt><code>pdf</code></dt>
<dd><p>Portable Document Format
</p></dd>
</dl>

<p>All device formats specified in <code>print</code> may also be used.  If
<var>fmt</var> is omitted it is extracted from the extension of <var>filename</var>.
The default format is <code>&quot;pdf&quot;</code>.
</p>
<div class="example">
<pre class="example">clf ();
surf (peaks);
saveas (1, &quot;figure1.png&quot;);
</pre></div>


<p><strong>See also:</strong> <a href="#XREFprint">print</a>, <a href="#XREForient">orient</a>.
</p></dd></dl>


<a name="XREForient"></a><dl>
<dt><a name="index-orient"></a>Function File: <em></em> <strong>orient</strong> <em>(<var>orientation</var>)</em></dt>
<dt><a name="index-orient-1"></a>Function File: <em></em> <strong>orient</strong> <em>(<var>hfig</var>, <var>orientation</var>)</em></dt>
<dt><a name="index-orient-2"></a>Function File: <em><var>orientation</var> =</em> <strong>orient</strong> <em>()</em></dt>
<dt><a name="index-orient-3"></a>Function File: <em><var>orientation</var> =</em> <strong>orient</strong> <em>(<var>hfig</var>)</em></dt>
<dd><p>Query or set the print orientation for figure <var>hfig</var>.
</p>
<p>Valid values for <var>orientation</var> are <code>&quot;portrait&quot;</code>,
<code>&quot;landscape&quot;</code>, and <code>&quot;tall&quot;</code>.
</p>
<p>The <code>&quot;landscape&quot;</code> option changes the orientation so the plot width
is larger than the plot height.  The <code>&quot;paperposition&quot;</code> is also
modified so that the plot fills the page, while leaving a 0.25 inch border.
</p>
<p>The <code>&quot;tall&quot;</code> option sets the orientation to <code>&quot;portrait&quot;</code> and
fills the page with the plot, while leaving a 0.25 inch border.
</p>
<p>The <code>&quot;portrait&quot;</code> option (default) changes the orientation so the plot
height is larger than the plot width.  It also restores the default
<code>&quot;paperposition&quot;</code> property.
</p>
<p>When called with no arguments, return the current print orientation.
</p>
<p>If the argument <var>hfig</var> is omitted, then operate on the current figure
returned by <code>gcf</code>.
</p>
<p><strong>See also:</strong> <a href="#XREFprint">print</a>, <a href="#XREFsaveas">saveas</a>.
</p></dd></dl>


<hr>
<div class="header">
<p>
Next: <a href="Interacting-with-Plots.html#Interacting-with-Plots" accesskey="n" rel="next">Interacting with Plots</a>, Previous: <a href="Use-of-the-interpreter-Property.html#Use-of-the-interpreter-Property" accesskey="p" rel="prev">Use of the <code>interpreter</code> Property</a>, Up: <a href="High_002dLevel-Plotting.html#High_002dLevel-Plotting" accesskey="u" rel="up">High-Level Plotting</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>