File: Printing-and-Saving-Plots.html

package info (click to toggle)
octave 10.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 145,388 kB
  • sloc: cpp: 335,976; ansic: 82,241; fortran: 20,963; objc: 9,402; sh: 8,756; yacc: 4,392; lex: 4,333; perl: 1,544; java: 1,366; awk: 1,259; makefile: 659; xml: 192
file content (819 lines) | stat: -rw-r--r-- 43,506 bytes parent folder | download | duplicates (2)
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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Printing and Saving Plots (GNU Octave (version 10.3.0))</title>

<meta name="description" content="Printing and Saving Plots (GNU Octave (version 10.3.0))">
<meta name="keywords" content="Printing and Saving Plots (GNU Octave (version 10.3.0))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="High_002dLevel-Plotting.html" rel="up" title="High-Level Plotting">
<link href="Interacting-with-Plots.html" rel="next" title="Interacting with Plots">
<link href="Use-of-the-_0022interpreter_0022-Property.html" rel="prev" title="Use of the &quot;interpreter&quot; Property">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.center {text-align:center}
div.example {margin-left: 3.2em}
kbd.kbd {font-style: oblique}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
ul.mark-bullet {list-style-type: disc}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">


</head>

<body lang="en">
<div class="subsection-level-extent" id="Printing-and-Saving-Plots">
<div class="nav-panel">
<p>
Next: <a href="Interacting-with-Plots.html" accesskey="n" rel="next">Interacting with Plots</a>, Previous: <a href="Use-of-the-_0022interpreter_0022-Property.html" accesskey="p" rel="prev">Use of the &quot;interpreter&quot; Property</a>, Up: <a href="High_002dLevel-Plotting.html" 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" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsection" id="Printing-and-Saving-Plots-1"><span>15.2.9 Printing and Saving Plots<a class="copiable-link" href="#Printing-and-Saving-Plots-1"> &para;</a></span></h4>
<a class="index-entry-id" id="index-plotting_002c-saving-and-printing-plots"></a>
<a class="index-entry-id" id="index-printing-plots"></a>
<a class="index-entry-id" id="index-saving-plots"></a>

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

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

<p>saves the current figure to a Portable Document encapsulated PostScript file
called <samp class="file">foo.pdf</samp>.
</p>
<p>The current graphic toolkits produce very similar graphic displays, but the
interpreters differ in their capability to display unusual text and in their
ability to print such text.  In general, the <code class="code">&quot;tex&quot;</code> interpreter
(default) is the best all-around performer for both on-screen display and
printing.  However, for the reproduction of complicated text formulas the
<code class="code">&quot;latex&quot;</code> interpreter is preferred.  The <code class="code">&quot;none&quot;</code> interpreter
prints text verbatim (exactly as it appears) which is very portable, but there
is no support for bold, italic, superscripts, subscripts, Greek letters, etc.
</p>
<p>When printing with the <samp class="option">-painters</samp> renderer, the default for all vector
formats, two options may be considered:
</p>
<ul class="itemize mark-bullet">
<li>Use the <samp class="option">-svgconvert</samp> option to allow for rendering LaTeX formulas.
Note that the glyph are rendered as path and the original textual info are
lost.

</li><li>Use one of the <samp class="option">-d*latex*</samp> devices to produce a .tex file (plus
supporting .eps or .pdf files) to be further processed by an external LaTeX
engine.  Note that the <code class="code">print</code> function will first set the interpreter of
all strings to <code class="code">&quot;latex&quot;</code>, which means all strings must be valid LaTeX
strings.
</li></ul>

<p>A complete example showing the capabilities of text printing using the
<samp class="option">-dpdflatexstandalone</samp> option is:
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">x = 0:0.01:3;
hf = figure ();
plot (x, erf (x));
hold on;
plot (x, x, &quot;r&quot;);
axis ([0, 3, 0, 1]);
text (0.65, 0.6175, ...
      ['$\displaystyle\leftarrow x = {2 \over \sqrt{\pi}}' ...
       '\int_{0}^{x} e^{-t^2} dt = 0.6175$'],
      &quot;interpreter&quot;, &quot;latex&quot;);
xlabel (&quot;x&quot;);
ylabel (&quot;erf (x)&quot;);
title (&quot;erf (x) with text annotation&quot;);
print (hf, &quot;plot15_7&quot;, &quot;-dpdflatexstandalone&quot;);
system (&quot;pdflatex plot15_7&quot;);
open plot15_7.pdf
</pre></div></div>

<p>The result of this example can be seen in <a class="ref" href="#fig_003aextendedtext">Figure 15.7</a>
</p>
<div class="float" id="fig_003aextendedtext">
<div class="center"><img class="image" src="extended.png" alt="extended">
</div><div class="caption"><p><strong class="strong">Figure 15.7: </strong>Example of inclusion of text with use of <samp class="option">-dpdflatexstandalone</samp></p></div></div>
<a class="anchor" id="XREFprint"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-print"><span><strong class="def-name">print</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-print"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-print-1"><span><strong class="def-name">print</strong> <code class="def-code-arguments">(<var class="var">options</var>)</code><a class="copiable-link" href="#index-print-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-print-2"><span><strong class="def-name">print</strong> <code class="def-code-arguments">(<var class="var">filename</var>, <var class="var">options</var>)</code><a class="copiable-link" href="#index-print-2"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-print-3"><span><strong class="def-name">print</strong> <code class="def-code-arguments">(<var class="var">hfig</var>, &hellip;)</code><a class="copiable-link" href="#index-print-3"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-print-4"><span><code class="def-type"><var class="var">RGB</var> =</code> <strong class="def-name">print</strong> <code class="def-code-arguments">(<code class="code">&quot;-RGBImage&quot;</code>, &hellip;)</code><a class="copiable-link" href="#index-print-4"> &para;</a></span></dt>
<dd><p>Format a figure for printing and either save it to a file, send it to a
printer, or return an RGB image.
</p>
<p><var class="var">filename</var> defines the name of the output file.  If the filename has
no suffix then one is inferred from the specified device and appended to the
filename.  When neither a filename nor the <code class="code">&quot;-RGBImage&quot;</code> option is
present, the output is sent to the printer.  The various options and
filename arguments may be given in any order, except for the figure handle
argument <var class="var">hfig</var> which must be first if it is present.
</p>
<p>Example: Print to a file using PDF and JPEG formats.
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">figure (1);
clf ();
surf (peaks);
print figure1.pdf    # The extension specifies the format
print -djpg figure1  # Will produce &quot;figure1.jpg&quot; file
</pre></div></div>

<p>If the first argument is a handle <var class="var">hfig</var> to a figure object then it
specifies the figure to print.  By default, the current figure returned
by <code class="code">gcf</code> is printed.
</p>
<p>For outputs to paged formats, for example, PostScript and PDF, the page size
is specified by the figure&rsquo;s <code class="code">papersize</code> property together with the
<code class="code">paperunits</code> property.  The location and size of the plot on the page
are specified by the figure&rsquo;s <code class="code">paperposition</code> property.  The
orientation of the page is specified by the figure&rsquo;s <code class="code">paperorientation</code>
property.
</p>
<p>For non-page formats&mdash;for example, image formats like JPEG&mdash;the width and
height of the output are specified by the figure&rsquo;s <code class="code">paperposition(3:4)</code>
property values.
</p>
<p>The <code class="code">print</code> command supports many <var class="var">options</var>:
</p>
<dl class="table">
<dt><code class="code">-f<var class="var">h</var></code></dt>
<dd><p>Specify the handle, <var class="var">h</var>, of the figure to be printed.
</p>
<p>Example: Print figure 1.
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">figure (1);
clf ();
surf (peaks);
figure (2);
print -f1 figure1.pdf
## Equivalent functional form:
print (1, &quot;figure1.pdf&quot;)
</pre></div></div>

</dd>
<dt><code class="code">-P<var class="var">printer</var></code></dt>
<dd><p>Set the <var class="var">printer</var> name to which the plot is sent if no <var class="var">filename</var>
is specified.
</p>
<p>Example: Print to printer named PS_printer using PostScript format.
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">clf ();
surf (peaks);
print -dpswrite -PPS_printer
</pre></div></div>

</dd>
<dt><code class="code">-RGBImage</code></dt>
<dd><p>Return an M-by-N-by-3 RGB image of the figure.  The size of the image
depends on the formatting options.  This is similar to taking a screen
capture of the plot, but formatting options may be changed such as the
resolution or monochrome/color.
</p>
<p>Example: Get the pixels of a figure image.
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">clf ();
surf (peaks);
<var class="var">rgb</var> = print (&quot;-RGBImage&quot;);
</pre></div></div>

</dd>
<dt><code class="code">-image | -opengl</code></dt>
<dt><code class="code">-vector | -painters</code></dt>
<dd><p>Specifies whether the pixel-based renderer (<samp class="option">-image</samp> or
<samp class="option">-opengl</samp>) or vector-based renderer (<samp class="option">-vector</samp> or
<samp class="option">-painters</samp>) is used.  This is equivalent to changing the figure&rsquo;s
<code class="code">&quot;Renderer&quot;</code> property.  When the figure
<code class="code">&quot;RendererMode&quot;</code> property is <code class="code">&quot;auto&quot;</code> (the default)
Octave will use the <code class="code">&quot;opengl&quot;</code> renderer for raster formats (e.g.,
JPEG) and <code class="code">&quot;painters&quot;</code> for vector formats (e.g., PDF).  These options
are only supported for the &quot;qt&quot; graphics toolkit.
</p>
</dd>
<dt><code class="code">-svgconvert (default)</code></dt>
<dt><code class="code">-nosvgconvert</code></dt>
<dd><p>When using the <samp class="option">-painters</samp> renderer, this enables or disables the
SVG based backend toolchain with enhanced characteristics:
</p>
<dl class="table">
<dt>Font handling:</dt>
<dd><p>For interpreters &quot;none&quot; and &quot;tex&quot;, the actual font is embedded in the output
file which allows for printing arbitrary characters and fonts in all vector
formats.
</p>
<p>Strings using the <code class="code">&quot;latex&quot;</code> interpreter, are rendered using path
objects.  This looks good but note that textual info (font,
characters&hellip;) are lost.
</p>
</dd>
<dt>Output Simplification:</dt>
<dd><p>By default, the option <samp class="option">-painters</samp> renders patch and surface objects
using assemblies of triangles.  This may lead to anti-aliasing artifacts
when viewing the file.  The <samp class="option">-svgconvert</samp> option reconstructs
polygons in order to avoid those artifacts (particularly for 2-D figures).
</p>
</dd>
<dt>Transparency:</dt>
<dd><p>Allows for printing transparent graphics objects in PDF format.
For PostScript formats the presence of any transparent object will cause the
output to be rasterized.
</p></dd>
</dl>

<p>Caution: If Octave was built against Qt version earlier than 5.13,
<samp class="option">-svgconvert</samp> may lead to inaccurate rendering of image objects.
</p>
</dd>
<dt><code class="code">-polymerge</code></dt>
<dt><code class="code">-nopolymerge</code></dt>
<dt><code class="code">-polymerge-all</code></dt>
<dd><p>When using the SVG based backend <samp class="option">-svgconvert</samp>, faces are rendered
as triangles.  In some cases, some viewers might display fine lines where
those triangles share an edge.  These options control whether all triangles
that share edges are merged into polygons (<samp class="option">-polymerge-all</samp> which
might take some time for graphics consisting of many triangles &ndash; including
line markers), only consecutive polygons are merged (<samp class="option">-polymerge</samp>),
or no triangles are merged at all (<samp class="option">-no-polymerge</samp>).  By default,
only consecutive triangles sharing an edge are merged, unless the printed
figure contains patch or surface graphics objects in which case all
triangles that are sharing an edge are merged.
</p>
</dd>
<dt><code class="code">-portrait</code></dt>
<dt><code class="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 class="code">&quot;paperposition&quot;</code> property in the
orientation specified.  This option is equivalent to changing the figure&rsquo;s
<code class="code">&quot;paperorientation&quot;</code> property.
</p>
</dd>
<dt><code class="code">-fillpage</code></dt>
<dt><code class="code">-bestfit</code></dt>
<dd><p>When using a page-based format (PDF, PostScript, printer) ignore the
<code class="code">&quot;paperposition&quot;</code> property and have the plot occupy the entire page.
The option <samp class="option">-fillpage</samp> will stretch the plot to occupy the page with
0.25 inch margins all around.  The option <samp class="option">-bestfit</samp> will expand the
plot to take up as much room as possible on the page <strong class="strong">without</strong>
distorting the original aspect ratio of the plot.
</p>
</dd>
<dt><code class="code">-color</code></dt>
<dt><code class="code">-mono</code></dt>
<dd><p>Color or monochrome output.
</p>
</dd>
<dt><code class="code">-solid</code></dt>
<dt><code class="code">-dashed</code></dt>
<dd><p>Force all lines to be solid or dashed, respectively.
</p>
</dd>
<dt><code class="code">-noui</code></dt>
<dd><p>Don&rsquo;t print uicontrol objects such as pushbuttons which may overlay the
plot.  This is the default behavior and it is not possible to include
uicontrol objects in the output without using an external screen capture
tool.
</p>
</dd>
<dt><code class="code">-r<var class="var">NUM</var></code></dt>
<dd><p>Resolution of bitmaps in dots per inch (DPI).  For both metafiles and SVG
the default is the screen resolution; for other formats the default is 150
DPI.  To specify screen resolution, use <code class="code">&quot;-r0&quot;</code>.
</p>
<p>Example: high resolution raster output.
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">clf ();
surf (peaks (), &quot;facelighting&quot;, &quot;gouraud&quot;);
light ();
print (&quot;-r600&quot;, &quot;lit_peaks.png&quot;);
</pre></div></div>

</dd>
<dt><code class="code">-S<var class="var">xsize</var>,<var class="var">ysize</var></code></dt>
<dd><p>Plot size in pixels for raster formats including PNG, JPEG, PNG, and
<em class="emph">unusually</em> SVG.  For all vector formats, including PDF, PS, and EPS,
the plot size is specified in points.  This option is equivalent to changing
the width and height of the output by setting the figure property
<code class="code">paperposition(3:4)</code>.  When using the command form of the print
function you must quote the <var class="var">xsize</var>,<var class="var">ysize</var> option to prevent the
Octave interpreter from recognizing the embedded comma (&rsquo;,&rsquo;).  For example,
by writing &quot;-S640,480&quot;<!-- /@w -->.
</p>
</dd>
<dt><code class="code">-tight</code></dt>
<dt><code class="code">-loose</code></dt>
<dd><p>Force a tight or loose bounding box for EPS files.  The default is tight.
</p>
</dd>
<dt><code class="code">-<var class="var">preview</var></code></dt>
<dd><p>Add a preview to EPS files.  Supported formats are:
</p>
<dl class="table">
<dt><code class="code">-interchange</code></dt>
<dd><p>Provide an interchange preview.
</p>
</dd>
<dt><code class="code">-metafile</code></dt>
<dd><p>Provide a metafile preview.
</p>
</dd>
<dt><code class="code">-pict</code></dt>
<dd><p>Provide a pict preview.
</p>
</dd>
<dt><code class="code">-tiff</code></dt>
<dd><p>Provide a TIFF preview.
</p></dd>
</dl>

</dd>
<dt><code class="code">-append</code></dt>
<dd><p>Append PostScript or PDF output to an existing file of the same type.
</p>
</dd>
<dt><code class="code">-F<var class="var">fontname</var></code></dt>
<dt><code class="code">-F<var class="var">fontname</var>:<var class="var">size</var></code></dt>
<dt><code class="code">-F:<var class="var">size</var></code></dt>
<dd><p>Use <var class="var">fontname</var> and/or <var class="var">fontsize</var> for all text.
<var class="var">fontname</var> is ignored for some devices: fig, etc.
</p>
</dd>
<dt><code class="code">-d<var class="var">device</var></code></dt>
<dd><p>The available output format is specified by the option <var class="var">device</var>, and
is one of the following (devices marked with a <code class="code">'*'</code> are only
available with the Gnuplot toolkit):
</p>
<p>Vector Formats
</p>
<dl class="table">
<dt><code class="code">svg</code></dt>
<dd><p>Scalable Vector Graphics.
</p>
</dd>
<dt><code class="code">pdf</code></dt>
<dt><code class="code">pdfcrop</code></dt>
<dd><p>Portable Document Format.  The <code class="code">pdf</code> device formats the figure for
printing on paper.  The size of the surrounding page and the position of the
figure inside the page are defined by the
<a class="ref" href="Figure-Properties.html#XREFfigurepaperorientation">paper* figure properties</a>.
</p>
<p>Use <code class="code">pdfcrop</code> if you don&rsquo;t want the surrounding page.
</p>
<p>Caution: with <samp class="option">-nosvgconvert</samp> option, PDF inherits the same
limitations as PostScript (limited set of fonts and lack of transparency).
</p>
</dd>
<dt><code class="code">eps(2)</code></dt>
<dt><code class="code">epsc(2)</code></dt>
<dd><p>Encapsulated PostScript (level 1 and 2, mono and color).
</p>
<p>The OpenGL-based graphics toolkits always generate PostScript level 3.0.
They have limited support for text unless using the <samp class="option">-svgconvert</samp>
option (the default).
Limitations include using only ASCII characters (e.g., no Greek letters)
and support for just three base PostScript fonts: Helvetica (the default),
Times, or Courier.  Any other font will be replaced by Helvetica.
</p>
</dd>
<dt><code class="code">ps(2)</code></dt>
<dt><code class="code">psc(2)</code></dt>
<dd><p>Same as <code class="code">eps</code> except that the figure is formatted for printing on
paper.  The size of the surrounding page and position of the figure inside
the page are defined by the
<a class="ref" href="Figure-Properties.html#XREFfigurepaperorientation">paper* figure properties</a>.
</p>
</dd>
<dt><code class="code">pslatex</code></dt>
<dt><code class="code">epslatex</code></dt>
<dt><code class="code">pdflatex</code></dt>
<dt><code class="code">pslatexstandalone</code></dt>
<dt><code class="code">epslatexstandalone</code></dt>
<dt><code class="code">pdflatexstandalone</code></dt>
<dd><p>Generate a LaTeX file <samp class="file"><var class="var">filename</var>.tex</samp> for the text portions
of a plot and a file <samp class="file"><var class="var">filename</var>.(ps|eps|pdf)</samp> for the remaining
graphics.  The graphics file suffix .ps|eps|pdf is determined by the
specified device type.  The LaTeX file produced by the &lsquo;<samp class="samp">standalone</samp>&rsquo;
option can be processed directly by LaTeX.  The file generated without
the &lsquo;<samp class="samp">standalone</samp>&rsquo; option is intended to be included from another
LaTeX document.  In either case, the LaTeX file contains an
<code class="code">\includegraphics</code> command so that the generated graphics file is
automatically included when the LaTeX file is processed.  The text that
is written to the LaTeX file contains the strings <strong class="strong">exactly</strong> as
they were specified in the plot.  If any special characters of the TeX
mode interpreter were used, the file must be edited before LaTeX
processing.  Specifically, the special characters must be enclosed with
dollar signs (<code class="code">$&nbsp;&hellip;&nbsp;$</code>)<!-- /@w -->, and other characters that are
recognized by LaTeX may also need editing (e.g., braces).  The
&lsquo;<samp class="samp">pdflatex</samp>&rsquo; device, and any of the &lsquo;<samp class="samp">standalone</samp>&rsquo; formats, are not
available with the Gnuplot toolkit.
</p>
</dd>
<dt><code class="code">epscairo*</code></dt>
<dt><code class="code">pdfcairo*</code></dt>
<dt><code class="code">epscairolatex*</code></dt>
<dt><code class="code">pdfcairolatex*</code></dt>
<dt><code class="code">epscairolatexstandalone*</code></dt>
<dt><code class="code">pdfcairolatexstandalone*</code></dt>
<dd><p>Generate output with Cairo renderer.  The devices <code class="code">epscairo</code> and
<code class="code">pdfcairo</code> are synonymous with the <code class="code">epsc</code> device.  The LaTeX
variants generate a LaTeX file, <samp class="file"><var class="var">filename</var>.tex</samp>, for the text
portions of a plot, and an image file, <samp class="file"><var class="var">filename</var>.(eps|pdf)</samp>, for
the graph portion of the plot.  The &lsquo;<samp class="samp">standalone</samp>&rsquo; variants behave as
described for &lsquo;<samp class="samp">epslatexstandalone</samp>&rsquo; above.
</p>
</dd>
<dt><code class="code">canvas*</code></dt>
<dd><p>Javascript-based drawing on an HTML5 canvas viewable in a web browser.
</p>
</dd>
<dt><code class="code">emf</code></dt>
<dt><code class="code">meta</code></dt>
<dd><p>Microsoft Enhanced Metafile
</p>
</dd>
<dt><code class="code">fig</code></dt>
<dd><p>XFig.  For the Gnuplot graphics toolkit, the additional options
<samp class="option">-textspecial</samp> or <samp class="option">-textnormal</samp> (default) can be used to
control whether the special flag should be set for the text in the figure.
</p>
</dd>
<dt><code class="code">latex*</code></dt>
<dt><code class="code">eepic*</code></dt>
<dd><p>LaTeX picture environment and extended picture environment.
</p>
</dd>
<dt><code class="code">tikz</code></dt>
<dt><code class="code">tikzstandalone*</code></dt>
<dd><p>Generate a LaTeX file using PGF/TikZ format.  The OpenGL-based
toolkits create a PGF file while Gnuplot creates a TikZ file.  The
&lsquo;<samp class="samp">tikzstandalone</samp>&rsquo; device produces a LaTeX document which includes the
TikZ file.
</p>
</dd>
</dl>

<p>Raster Formats
</p>
<dl class="table">
<dt><code class="code">png</code></dt>
<dd><p>Portable Network Graphics
</p>
</dd>
<dt><code class="code">jpg</code></dt>
<dt><code class="code">jpeg</code></dt>
<dd><p>JPEG image
</p>
</dd>
<dt><code class="code">tif</code></dt>
<dt><code class="code">tiff</code></dt>
<dt><code class="code">tiffn</code></dt>
<dd><p>TIFF image with LZW compression (tif, tiff) or uncompressed
(tiffn).
</p>
</dd>
<dt><code class="code">gif</code></dt>
<dd><p>GIF image
</p>
</dd>
<dt><code class="code">pbm</code></dt>
<dd><p>PBMplus
</p>
</dd>
<dt><code class="code">dumb*</code></dt>
<dd><p>ASCII art
</p>
</dd>
</dl>

<p>If the device is omitted, it is inferred from the file extension,
or if there is no filename then it is sent to the printer as PostScript.
</p>
</dd>
<dt><code class="code">-d<var class="var">ghostscript_device</var></code></dt>
<dd><p>Additional devices are supported by Ghostscript.
Some examples are:
</p>
<dl class="table">
<dt><code class="code">ljet2p</code></dt>
<dd><p>HP LaserJet IIP
</p>
</dd>
<dt><code class="code">pcx24b</code></dt>
<dd><p>24-bit color PCX file format
</p>
</dd>
<dt><code class="code">ppm</code></dt>
<dd><p>Portable Pixel Map file format
</p></dd>
</dl>

<p>For a complete list of available formats and devices type
<kbd class="kbd">system (&quot;gs -h&quot;)</kbd>.
</p>
<p>When Ghostscript output is sent to a printer the size is determined by
the figure&rsquo;s <code class="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 class="code">&quot;paperposition&quot;</code> property.
</p>
</dd>
<dt><code class="code">-G<var class="var">ghostscript_command</var></code></dt>
<dd><p>Specify the command for calling Ghostscript.  For Unix the default is
<code class="code">&quot;gs&quot;</code> and for Windows it is <code class="code">&quot;gswin32c&quot;</code>.
</p>
</dd>
<dt><code class="code">-TextAlphaBits=<var class="var">n</var></code></dt>
<dt><code class="code">-GraphicsAlphaBits=<var class="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 are 4 and 1
respectively.  Allowed values for <var class="var">N</var> are 1, 2, or 4.
</p>
</dd>
<dt><code class="code">-no-append-file-extension</code></dt>
<dd><p>With this option, <var class="var">filename</var> is used verbatim.  That means no file
extension matching the file format is appended automatically.
</p></dd>
</dl>


<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFsaveas">saveas</a>, <a class="ref" href="Representing-Images.html#XREFgetframe">getframe</a>, <a class="ref" href="#XREFsavefig">savefig</a>, <a class="ref" href="#XREFhgsave">hgsave</a>, <a class="ref" href="#XREForient">orient</a>, <a class="ref" href="Multiple-Plot-Windows.html#XREFfigure">figure</a>.
</p></dd></dl>


<a class="anchor" id="XREFsaveas"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-saveas"><span><strong class="def-name">saveas</strong> <code class="def-code-arguments">(<var class="var">h</var>, <var class="var">filename</var>)</code><a class="copiable-link" href="#index-saveas"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-saveas-1"><span><strong class="def-name">saveas</strong> <code class="def-code-arguments">(<var class="var">h</var>, <var class="var">filename</var>, <var class="var">fmt</var>)</code><a class="copiable-link" href="#index-saveas-1"> &para;</a></span></dt>
<dd><p>Save graphics object <var class="var">h</var> to the file <var class="var">filename</var> in graphics format
<var class="var">fmt</var>.
</p>
<p>If <var class="var">h</var> is the handle to a figure object, that figure object is saved.
If <var class="var">h</var> is the handle to a different graphics object, the figure
containing that graphics object is saved.
</p>
<p>All device formats accepted by <code class="code">print</code> may be used.  Common formats
are:
</p>
<dl class="table">
<dt><code class="code">ofig</code></dt>
<dd><p>Octave figure file format (default)
</p>
</dd>
<dt><code class="code">mfig</code></dt>
<dd><p>Two files: Octave m-file <samp class="file">filename.m</samp> containing code
    to open Octave figure file <samp class="file">filename.ofig</samp>
</p>
</dd>
<dt><code class="code">ps</code></dt>
<dd><p>PostScript
</p>
</dd>
<dt><code class="code">eps</code></dt>
<dd><p>Encapsulated PostScript
</p>
</dd>
<dt><code class="code">pdf</code></dt>
<dd><p>Portable Document Format
</p>
</dd>
<dt><code class="code">jpg</code></dt>
<dd><p>JPEG Image
</p>
</dd>
<dt><code class="code">png</code></dt>
<dd><p>Portable Network Graphics image
</p>
</dd>
<dt><code class="code">emf</code></dt>
<dd><p>Enhanced MetaFile
</p>
</dd>
<dt><code class="code">tif</code></dt>
<dd><p>TIFF Image, compressed
</p>
</dd>
</dl>

<p>If <var class="var">fmt</var> is omitted it is extracted from the extension of
<var class="var">filename</var>.  The default format when there is no extension is
<code class="code">&quot;ofig&quot;</code>.
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">clf ();
surf (peaks);
saveas (1, &quot;figure1.png&quot;);
</pre></div></div>


<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFprint">print</a>, <a class="ref" href="#XREFsavefig">savefig</a>, <a class="ref" href="#XREFhgsave">hgsave</a>, <a class="ref" href="#XREForient">orient</a>.
</p></dd></dl>


<a class="anchor" id="XREForient"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-orient"><span><strong class="def-name">orient</strong> <code class="def-code-arguments">(<var class="var">orientation</var>)</code><a class="copiable-link" href="#index-orient"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-orient-1"><span><strong class="def-name">orient</strong> <code class="def-code-arguments">(<var class="var">hfig</var>, <var class="var">orientation</var>)</code><a class="copiable-link" href="#index-orient-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-orient-2"><span><code class="def-type"><var class="var">orientation</var> =</code> <strong class="def-name">orient</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-orient-2"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-orient-3"><span><code class="def-type"><var class="var">orientation</var> =</code> <strong class="def-name">orient</strong> <code class="def-code-arguments">(<var class="var">hfig</var>)</code><a class="copiable-link" href="#index-orient-3"> &para;</a></span></dt>
<dd><p>Query or set the print orientation for figure <var class="var">hfig</var>.
</p>
<p>Valid values for <var class="var">orientation</var> are <code class="code">&quot;portrait&quot;</code>,
<code class="code">&quot;landscape&quot;</code>, and <code class="code">&quot;tall&quot;</code>.
</p>
<p>The <code class="code">&quot;landscape&quot;</code> option changes the orientation so the plot width
is larger than the plot height.  The <code class="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 class="code">&quot;tall&quot;</code> option sets the orientation to <code class="code">&quot;portrait&quot;</code> and
fills the page with the plot, while leaving a 0.25 inch border.
</p>
<p>The <code class="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 class="code">&quot;paperposition&quot;</code> property.
</p>
<p>When called with no arguments, return the current print orientation.
</p>
<p>If the argument <var class="var">hfig</var> is omitted, then operate on the current figure
returned by <code class="code">gcf</code>.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFprint">print</a>, <a class="ref" href="#XREFsaveas">saveas</a>.
</p></dd></dl>


<p><code class="code">print</code> and <code class="code">saveas</code> are used when work on a plot has finished
and the output must be in a publication-ready format.  During intermediate
stages it is often better to save the graphics object and all of its
associated information so that changes&mdash;to colors, axis limits, marker styles,
etc.&mdash;can be made easily from within Octave.  The <code class="code">hgsave</code>/<code class="code">hgload</code>
commands can be used to save and re-create a graphics object.
</p>
<a class="anchor" id="XREFhgsave"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-hgsave"><span><strong class="def-name">hgsave</strong> <code class="def-code-arguments">(<var class="var">filename</var>)</code><a class="copiable-link" href="#index-hgsave"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-hgsave-1"><span><strong class="def-name">hgsave</strong> <code class="def-code-arguments">(<var class="var">h</var>, <var class="var">filename</var>)</code><a class="copiable-link" href="#index-hgsave-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-hgsave-2"><span><strong class="def-name">hgsave</strong> <code class="def-code-arguments">(<var class="var">h</var>, <var class="var">filename</var>, <var class="var">fmt</var>)</code><a class="copiable-link" href="#index-hgsave-2"> &para;</a></span></dt>
<dd><p>Save the graphics handle(s) <var class="var">h</var> to the file <var class="var">filename</var> in the format
<var class="var">fmt</var>.
</p>
<p>If unspecified, <var class="var">h</var> is the current figure as returned by <code class="code">gcf</code>.
</p>
<p>When <var class="var">filename</var> does not have an extension the default filename
extension <samp class="file">.ofig</samp> will be appended.
</p>
<p>If present, <var class="var">fmt</var> must be one of the following:
</p>
<ul class="itemize mark-bullet">
<li><samp class="option">-binary</samp>, <samp class="option">-float-binary</samp>

</li><li><samp class="option">-hdf5</samp>, <samp class="option">-float-hdf5</samp>

</li><li><samp class="option">-V7</samp>, <samp class="option">-v7</samp>, <samp class="option">-7</samp>, <samp class="option">-mat7-binary</samp>

</li><li><samp class="option">-V6</samp>, <samp class="option">-v6</samp>, <samp class="option">-6</samp>, <samp class="option">-mat6-binary</samp>

</li><li><samp class="option">-text</samp>

</li><li><samp class="option">-zip</samp>, <samp class="option">-z</samp>
</li></ul>

<p>The default format is <samp class="option">-binary</samp> to minimize storage.
</p>
<p>Programming Note: When producing graphics for final publication use
<code class="code">print</code> or <code class="code">saveas</code>.  When it is important to be able to continue
to edit a figure as an Octave object, use <code class="code">hgsave</code>/<code class="code">hgload</code>.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFhgload">hgload</a>, <a class="ref" href="Handle-Functions.html#XREFhdl2struct">hdl2struct</a>, <a class="ref" href="#XREFsavefig">savefig</a>, <a class="ref" href="#XREFsaveas">saveas</a>, <a class="ref" href="#XREFprint">print</a>.
</p></dd></dl>


<a class="anchor" id="XREFhgload"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-hgload"><span><code class="def-type"><var class="var">h</var> =</code> <strong class="def-name">hgload</strong> <code class="def-code-arguments">(<var class="var">filename</var>)</code><a class="copiable-link" href="#index-hgload"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-hgload-1"><span><code class="def-type">[<var class="var">h</var>, <var class="var">old_prop</var>] =</code> <strong class="def-name">hgload</strong> <code class="def-code-arguments">(<var class="var">filename</var>, <var class="var">prop_struct</var>)</code><a class="copiable-link" href="#index-hgload-1"> &para;</a></span></dt>
<dd><p>Load the graphics objects in <var class="var">filename</var> into a vector of graphics
handles <var class="var">h</var>.
</p>
<p>If <var class="var">filename</var> has no extension, Octave will try to find the file with
and without the default extension <samp class="file">.ofig</samp>.
</p>
<p>If provided, the elements of structure <var class="var">prop_struct</var> will be used to
override the properties of top-level objects stored in <var class="var">filename</var>, and
the saved values from <var class="var">filename</var> will be stored in <var class="var">old_prop</var>.
<var class="var">old_prop</var> is a cell array matching the size of <var class="var">h</var>; each cell
contains a structure of the existing property names and values before being
overridden.
</p>

<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFopenfig">openfig</a>, <a class="ref" href="#XREFhgsave">hgsave</a>, <a class="ref" href="Handle-Functions.html#XREFstruct2hdl">struct2hdl</a>.
</p></dd></dl>


<a class="anchor" id="XREFopenfig"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-openfig"><span><strong class="def-name">openfig</strong><a class="copiable-link" href="#index-openfig"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-openfig-1"><span><strong class="def-name">openfig</strong> <code class="def-code-arguments">(<var class="var">filename</var>)</code><a class="copiable-link" href="#index-openfig-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-openfig-2"><span><strong class="def-name">openfig</strong> <code class="def-code-arguments">(&hellip;, <var class="var">copies</var>)</code><a class="copiable-link" href="#index-openfig-2"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-openfig-3"><span><strong class="def-name">openfig</strong> <code class="def-code-arguments">(&hellip;, <var class="var">visibility</var>)</code><a class="copiable-link" href="#index-openfig-3"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-openfig-4"><span><code class="def-type"><var class="var">h</var> =</code> <strong class="def-name">openfig</strong> <code class="def-code-arguments">(&hellip;)</code><a class="copiable-link" href="#index-openfig-4"> &para;</a></span></dt>
<dd><p>Read saved figure window(s) from <var class="var">filename</var> and return graphics
handle(s) <var class="var">h</var>.
</p>
<p>By default, <var class="var">filename</var> is <code class="code">&quot;Untitled.fig&quot;</code>.  If a full path is not
specified, the file opened will be the first one encountered in the load
path.  If <var class="var">filename</var> is not found and does not have an extension, a
search will take place for the first file in the load path with extension
<code class="code">&quot;.fig&quot;</code> or <code class="code">&quot;.ofig&quot;</code>, in that order.
</p>
<p><var class="var">copies</var> is an optional input indicating whether a new figure should
be created (<code class="code">&quot;new&quot;</code>) or whether an existing figure may be reused
(<code class="code">&quot;reuse&quot;</code>).  An existing figure may be reused if the
<code class="code">&quot;FileName&quot;</code> property matches the specified input <var class="var">filename</var>.
When a figure is reused it becomes the active figure and is shown on top
of other figures.  If the figure was offscreen, it is re-positioned to be
onscreen.  The default value for <var class="var">copies</var> is <code class="code">&quot;new&quot;</code>.
</p>
<p><var class="var">visibility</var> is an optional input indicating whether to show the figure
(<code class="code">&quot;visible&quot;</code>) or not (<code class="code">&quot;invisible&quot;</code>).  When <var class="var">visibility</var> is
specified as an input to <code class="code">openfig</code> it overrides the visibility setting
stored in <var class="var">filename</var>.
</p>

<p><strong class="strong">See also:</strong> <a class="ref" href="Controlling-Subprocesses.html#XREFopen">open</a>, <a class="ref" href="#XREFhgload">hgload</a>, <a class="ref" href="#XREFsavefig">savefig</a>, <a class="ref" href="Handle-Functions.html#XREFstruct2hdl">struct2hdl</a>.
</p></dd></dl>


<a class="anchor" id="XREFsavefig"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-savefig"><span><strong class="def-name">savefig</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-savefig"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-savefig-1"><span><strong class="def-name">savefig</strong> <code class="def-code-arguments">(<var class="var">h</var>)</code><a class="copiable-link" href="#index-savefig-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-savefig-2"><span><strong class="def-name">savefig</strong> <code class="def-code-arguments">(<var class="var">filename</var>)</code><a class="copiable-link" href="#index-savefig-2"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-savefig-3"><span><strong class="def-name">savefig</strong> <code class="def-code-arguments">(<var class="var">h</var>, <var class="var">filename</var>)</code><a class="copiable-link" href="#index-savefig-3"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-savefig-4"><span><strong class="def-name">savefig</strong> <code class="def-code-arguments">(<var class="var">h</var>, <var class="var">filename</var>, <code class="code">&quot;compact&quot;</code>)</code><a class="copiable-link" href="#index-savefig-4"> &para;</a></span></dt>
<dd><p>Save figure windows specified by graphics handle(s) <var class="var">h</var> to file
<var class="var">filename</var>.
</p>
<p>If unspecified, <var class="var">h</var> is the current figure returned by <code class="code">gcf</code>.
</p>
<p>If unspecified, <var class="var">filename</var> is set to <samp class="file">&quot;Untitled.fig&quot;</samp>.  If
<var class="var">filename</var> does not have an extension then the default extension
<samp class="file">&quot;.fig&quot;</samp> will be added.
</p>
<p>If the optional third input <code class="code">&quot;compact&quot;</code> is present then the data
will be compressed to save more space.
</p>

<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFhgsave">hgsave</a>, <a class="ref" href="Handle-Functions.html#XREFhdl2struct">hdl2struct</a>, <a class="ref" href="#XREFopenfig">openfig</a>.
</p></dd></dl>


</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Interacting-with-Plots.html">Interacting with Plots</a>, Previous: <a href="Use-of-the-_0022interpreter_0022-Property.html">Use of the &quot;interpreter&quot; Property</a>, Up: <a href="High_002dLevel-Plotting.html">High-Level Plotting</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>