Graph

Any graph that you produce in Stata will appear in a new pop-up window.

Edit a graph

You can adjust your graph at any time by:

  • Right-click on the graph.
  • Choose Start Graph Editor.

This turns the pop-up window into the graph editor.

The remaining functions available here will not be covered in this guide – but we strongly encourage you to experiment!

The bottom line is that you double-click on the things you want to change, in order to activate different options.

Note
As long as the graph editor is open, you cannot do anything in your dataset or do-file (they are “locked”).

To exit the Graph Editor:

  • Go to the menu bar in the graph editor.
  • Click on File\Stop Graph Editor.

If you have made any changes, you will be asked whether you want to save those or not.

More information
help graph editor

Save a graph

You can save your graph by using the following command in the do-file (note that this does not work if the graph editor is open):

graph save "pathfilename.gph"

Change “pathfilename” to the full path (i.e. the folder on your computer that you want the file to end up in), and specify the file name of your choice, such as:

graph save "C:\Users\yerik\Stata Guide\Srh.gph"

This only works the first time you save the graph. If you want to overwrite a graph, you need to specify the command like this:

graph save "C:\Users\yerik\Stata Guide\Srh.gph", replace
More information
help graph save

Open a graph

You can open a graph by using the following command in the do-file:

graph use "pathfilename.do"

Change “pathfilename” to the full path (i.e. the folder on your computer that contains the file), and specify the file name, such as:

graph use "C:\Users\yerik\Stata Guide\Srh.gph"
More information
help graph use