Friday, July 31, 2020

Trick for Making Lots of Pretty Graphs In Stata

Two main points to make in this today. 

1. MOST IMPORTANT: Make graphs! Graphs are so much better than tables. Also note: do as I say, not as a I do.
2. But speaking of do's...David McKenzie has a nice trick for how to make those graphs good looking using do files! I'll copy-paste here for convenience, but all credit goes to him. 


 Stata trick I learned this week: often I create graphs in Stata, and then want to pretty them up using Stata’s graph editor. But while you can record what you do in the graph editor as a .grec file, this is a pain for replicability since you need to go in and edit each time. I learned you should do the following steps:

1)       Open the graph editor, start recording, and do the editing you want, and save the editing file as a .grec file.

2)       Then open the .grec file, and you will see a bunch of commands. Take these commands and add gr_edit in front of them in your main do file.

E.g. now my do file would read something like

graph use "output\myfigure.gph"

gr_edit style.editstyle boxstyle(shadestyle(color(white))) editcopy

gr_edit legend.style.editstyle boxstyle(linestyle(color(white))) editcopy

gr_edit yaxis1.title.DragBy -.1931240126534509 -2.317488151841824

No comments:

Post a Comment