Stata 15 help for graph_manipulation

[G-2] graph manipulation -- Graph manipulation commands

Syntax

Command Description ------------------------------------------------------------------------- graph dir list names of graphs graph describe describe contents of graph graph drop discard graph stored in memory graph close close Graph window graph rename rename graph stored in memory graph copy copy graph stored in memory graph export export current graph

graph use load graph on disk into memory and display it graph display redisplay graph stored in memory graph combine combine multiple graphs graph replay redisplay graphs stored in memory and on disk -------------------------------------------------------------------------

Description

The graph manipulation commands manipulate graphs stored in memory or stored on disk.

Remarks

Remarks are presented under the following headings:

Overview of graphs in memory and graphs on disk Summary of graph manipulation commands

Overview of graphs in memory and graphs on disk

Graphs are stored in memory and on disk. When you draw a graph, such as by typing

. graph twoway scatter mpg weight

the resulting graph is stored in memory, and, in particular, it is stored under the name Graph. Were you next to type

. graph matrix mpg weight displ

this new graph would replace the existing graph named Graph.

Graph is the default name used to record graphs in memory, and when you draw graphs, they replace what was previously recorded in Graph.

You can specify the name() option -- see [G-3] name_option -- to record graphs under different names:

. graph twoway scatter mpg weight, name(scat)

Now there are two graphs in memory: Graph, containing a scatterplot matrix, and scat, containing a graph of mpg versus weight.

Graphs in memory are forgotten when you exit Stata, and they are forgotten at other times, too, such as when you type clear or discard; see [D] drop and [P] discard.

Graphs can be stored on disk, where they will reside permanently until you erase them. They are saved in files known as .gph files -- files whose names end in .gph; see gph files.

You can save on disk the graph currently showing in the Graph window by typing

. graph save mygraph.gph

The result is to create a new file mygraph.gph; see [G-2] graph save. Or -- see [G-3] saving_option -- you can save on disk graphs when you originally draw them:

. graph twoway scatter mpg weight, saving(mygraph.gph)

Either way, graphs saved on disk can be reloaded:

. graph use mygraph.gph

loads mygraph.gph into memory under the name -- you guessed it -- Graph. Of course, you could load it under a different name:

. graph use mygraph.gph, name(memcp)

Having brought this graph back into memory, you find that things are just as if you had drawn the graph for the first time. Anything you could do back then -- such as combine the graph with other graphs or change its aspect ratio -- you can do now. And, of course, after making any changes, you can save the result on disk, either replacing file mygraph.gph or saving it under a new name.

There is only one final, and minor, wrinkle: graphs on disk can be saved in either of two formats, known as live and asis. live is preferred and is the default, and what was said above applies only to live-format files. asis files are more like pictures -- all you can do is admire them and make copies. To save a file in asis format, you type

. graph save ..., asis or . graph ..., ... saving(..., asis)

asis format is discussed in gph files.

There is a third format called old, which is like asis, except that it refers to graphs made by versions of Stata older than Stata 8. This is discussed in gph files, too.

Summary of graph manipulation commands

The graph manipulation commands help you manage your graphs, whether stored in memory or on disk. The commands are

graph dir Lists the names under which graphs are stored, both in memory and on disk; see [G-2] graph dir.

graph describe Provides details about a graph, whether stored in memory or on disk; see [G-2] graph describe.

graph drop Eliminates from memory graphs stored there; see [G-2] graph drop.

graph close Closes Graph windows; see [G-2] graph close.

graph rename Changes the name of a graph stored in memory; see [G-2] graph rename.

graph copy Makes a copy of a graph stored in memory; see [G-2] graph copy.

graph export Exports the graph currently displayed in the Graph window to a file; see [G-2] graph export.

graph use Copies a graph on disk into memory and displays it; see [G-2] graph use.

graph display Redisplays a graph stored in memory; see [G-2] graph display.

graph combine Combines graphs stored in memory or on disk; see [G-2] graph combine.

graph replay Redisplays graphs stored in memory and on disk; see [G-2] graph replay.


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