Stata 15 help for graph_print

[G-2] graph print -- Print a graph

Syntax

graph print [, name(windowname) pr_options]

Description

graph print prints the graph displayed in a Graph window.

Stata for Unix users must do some setup before using graph print for the first time; see Appendix: Setting up Stata for Unix to print graphs below.

Options

name(windowname) specifies which window to print when printing a graph. The default is for Stata to print the topmost graph (Unix(GUI) users: see Technical note for Stata for Unix(GUI) users).

The window name is located inside parentheses in the window title. For example, if the title for a Graph window is Graph (MyGraph), the name for the window is MyGraph. If a graph is an asis or graph7 graph, where there is no name in the window title, then specify "" for windowname.

pr_options modify how the graph is printed. See [G-3] pr_options.

Default values for the options may be set using [G-2] graph set.

Remarks

Graphs are printed by displaying them on the screen and then typing

. graph print

Remarks are presented under the following headings:

Printing the graph displayed in a Graph window Printing a graph stored on disk Printing a graph stored in memory Appendix: Setting up Stata for Unix to print graphs

Also see [G-2] set printcolor. By default, if the graph being printed has a black background, it is printed in monochrome.

In addition to printing graphs, Stata can export graphs in PostScript, Encapsulated PostScript (EPS), Portable Network Graphics (PNG), TIFF, Windows Metafile (WMF), and Windows Enhanced Metafile (EMF); see [G-2] graph export.

Printing the graph displayed in a Graph window

There are three ways to print the graph displayed in a Graph window:

1. Right-click in the Graph window, and select Print....

2. Select File > Print Graph....

3. Type "graph print" in the Command window. Stata for Unix(GUI) users should use the name() option if there is more than one graph displayed to ensure that the correct graph is printed (see Technical note for Stata for Unix(GUI) users).

All are equivalent. The advantage of graph print is that you may include it in do-files:

. graph ... (draw a graph)

. graph print (and print it)

Printing a graph stored on disk

To print a graph stored on disk, type

. graph use filename

. graph print

Do not specify graph use's nodraw option; see [G-2] graph use.

Stata for Unix(console) users: follow the instructions just given, even though you have no Graph window and cannot see what has just been "displayed". Use the graph, and then print it.

Printing a graph stored in memory

To print a graph stored in memory but not currently displayed, type

. graph display name

. graph print

Do not specify graph display's nodraw option; see [G-2] graph display.

Stata for Unix(console) users: follow the instructions just given, even though you have no Graph window and cannot see what has just been "displayed". Display the graph, and then print it.

Appendix: Setting up Stata for Unix to print graphs

Before you can print graphs, you must tell Stata the command you ordinarily use to print PostScript files. By default, Stata assumes that the command is

$ lpr < filename

That command may be correct for you. If, on the other hand, you usually type something like

$ lpr -Plexmark filename

you need to tell Stata that by typing

. printer define prn ps "lpr -Plexmark @"

Type an @ where you ordinarily would type the filename. If you want the command to be "lpr -Plexmark < @", type

. printer define prn ps "lpr -Plexmark < @"

Stata assumes that the printer you specify understands PostScript format.

Technical note for Stata for Unix users

Stata for Unix uses PostScript to print graphs. If the graph you wish to print contains Unicode characters, those characters may not appear correctly in PostScript files because the PostScript fonts do not support Unicode. Stata will map as many characters as possible to characters supported by Unicode but will print a question mark (?) for any unsupported character. We recommend that you export the graph to a PDF file, which has fonts with better support for Unicode characters. See [G-2] graph export.

Technical note for Stata for Unix(GUI) users

X-Windows does not have the concept of a window z-order, which prevents Stata from determining which window is the topmost window. Instead, Stata determines which window is topmost based on which window has the focus. However, some window managers will set the focus to a window without bringing the window to the top. What Stata considers the topmost window may not appear topmost visually. For this reason, you should always use the name() option to ensure that the correct Graph window is printed.


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index