help graphoutalso see: graphsto, statsto, statout

Title

graphout -- Format and save graphs | 08June2012

Overview

graphout saves graphs to a text file specified by using
file_name, where .extension can be ".rtf" for RTF, ".html"
for HTML, or ".tex" for TEX files. The .extension for both graph and
file names must be specified.

NOTE: RTF, HTML, and TEX files created by graphout contain links to the specified graphs. To embed graphs, HTML and RTF files must be
converted to a PDF, and TEX files must be "typeset." Otherwise, the graphs and file must remain in the same folder to be viewed in the file.

For more information and examples, please visit the Collect Website.

General syntax

graphout [graph_name] using file_name [ ,
options ]

where graph_name includes one or more graph
names and their appropriate file extension, and file_name is the
name of the file where the graph(s) will be saved.

Table of contents

1. File format
2. Output
3. Size
4. Layout
5. Text
6. Advanced
7. Examples

Options

File format

The file format can be RTF, TEX, HTML and must be specified in
.extension of file_name.

.rtf produces a Rich Text Format file for use with word
processors. To view graphs in RTF files, the file must be opened in a word
processsor.

.html produces a HTML formatted file.

.tex produces a LaTeX formatted file.

as(fileformat) may be used to specify the
graph format. For example, file_format could be .png or .eps.

Output

replace Overwrite an existing file

append Append the output to an existing file

Size

These options are available for HTML and TEX files.

height(string) may be used to specify the
height of the graphs in TEX or HTML files.

width(string) may be used to specify the
width of the graphs in TEX or HTML files.

For TEX files, string should be a nonnegative number along with
the units of measure (mm, cm, in). For example, to create a file with graphs
that are 5in tall by 5in wide, type height(5in)
width(5in).

In HTML mode string should be only be a nonnegative number, which refers
to the number of pixels. For example, to create a file with graphs that are
100 pixels tall by 100 pixels wide, type height(100)
width(100).

scale(#) must range between 0 and 1 and may be used to
specify how to scale the graphs in TEX or HTML files.

For HTML and TEX files, # should be a nonnegative number between 0 and 1.
For example, to create a file with graphs that are half the size of the
orginal, type scale(.5).

Layout

These options are available for RTF, HTML, and TEX files.

alignment(string) may be used to specify the
alignment (center, left, or right align) of the graphs. string should be one of the following alignments: center or c, right or
r, left or l.

Text

These options are available for RTF, HTML, and TEX files.

title(string[, subopts]) may be used to add a title to
graphs. The title must be placed within quotes if it contains a comma.

subopts
above places graph title above graph.
below places graph title below graph.

note(string) may be used to add a note below
graphs.

nocount without this option, "Figure #" is added before each graph.

basecount(numlist) specifies what # "Figure #" starts with.

Advanced

These options are available for TEX files.

placement(string) may be used to adjust the placement of
a float in LaTeX document.

string Figure is placed at:
h roughly the location in the source text

t the top of the page

b the bottom of the page

p a special page for floats only

H precise location in text (requires "float" package)

fbarrier(#) adds "\FloatBarrier" command to every #th figure. If document is specified, "placeins" package is added to TEX file. If not, "placeins" package must be added manually to main TEX document.

In LaTeX documents, too many floats can cause an error - "Too many
unprocessed floats." This option will avoid this error.

document adds \documentclass{article}, \usepackage{graphicx}, and
\begin{document} to the begining of a TEX document and \end{document} to the
end of the document.

label(string) adds \label{string} to TEX files. This option automatically turns figures into floats.

Exmamples

Below are several basic examples of graphout.

. sysuse auto
(1978 Automobile Data)

Add graphs to a HTML file.

. histogram price, freq
(bin=8, start=3291, width=1576.875)

. graph export g1.png, replace
(file g1.png written in PNG format)

. graphout g1.png using example.html, ///
> replace title(Fig1: Price Histogram) scale(.5)
(file example.html written in HTML format)

. graph twoway scatter price mpg

. graph export g2.png, replace
(file g2.png written in PNG format)

. graphout g2.png using example.html, ///
> append title(Fig2: Price MPG Scatter) scale(.5)

Add graphs to a TEX file.

. histogram price, freq
(bin=8, start=3291, width=1576.875)

. graph export g3.eps, replace
(file g3.eps written in EPS format)

. graphout g3.eps using example.tex, ///
> replace title(Price Histogram) scale(.5) align(c) ///
> note(Now with LaTeX)
(file example.tex written in TEX format)

.
. graph twoway scatter price mpg

. graph export g4.eps, replace
(file g4.eps written in EPS format)

. graphout g4.eps using example.tex, ///
> append title(Price MPG Scatter) scale(.5) align(c)

Add graphs to RTF file.

. histogram trunk, freq
(bin=8, start=5, width=2.25)

. graph export g5.eps, replace
(file g5.eps written in EPS format)

. graphout g5.eps using example.rtf, ///
> replace title(Fig1: Price Histogram) align(l)
(file example.rtf written in RTF format)

.
. graph twoway scatter price weight, title()

. graph export g6.eps, replace
(file g6.eps written in EPS format)

. graphout g6.eps using example.rtf, ///
> append title(Fig2: Price MPG Scatter) align(l)

Add several graphs at once

. loc count = 0

. foreach var of varlist mpg-length {
2. loc ++count
3. graph twoway scatter price `var',title(Price & `var')
4. graph export g`count'.eps, replace
5. }
(file g1.eps written in EPS format)
(file g2.eps written in EPS format)
(file g3.eps written in EPS format)
(file g4.eps written in EPS format)
(file g5.eps written in EPS format)
(file g6.eps written in EPS format)

. graphout g1.eps g2.eps g3.eps g4.eps g5.eps g6.eps ///
using example2.rtf
(file example2.rtf written in RTF format)

Authors

Joseph D. Wolfe, Indiana University, jdwolfe@indiana.edu

J. Scott Long, Indiana University, jslong@indiana.edu

Also see

Manual: [G] graph

Website: Collect Website