Getting More Out of Stata’s Graph Editor: A Concise Guide
Graph Editor (GE) is a helpful feature in Stata, allowing users to manually change virtually any aspect of their graphs via point-and-click. Unfortunately, there aren’t many concise tutorials on using GE, and some of GE’s coolest features remain surprisingly unknown. Whether you are just starting out with Stata or have been using it for years, this guide is here to help you get more out of GE.
Introduction
One of Stata’s most helpful features is undoubtedly Graph Editor (GE). GE allows users to manually edit pretty much any aspect of their graphs. Colors, shapes, text, lines, dimensions, margins — all of it can be adjusted via GE by simply pointing and clicking on it. This is because Stata’s default is to generate graphs as an editable (.gph) file, rather than as a .png or .pdf.
When is using GE especially helpful? Three common situations:
- When you (the user) don’t know the code for changing some aspect of your graph
- When you want to quickly experiment with different colors, shapes, sizes, etc. for aesthetic purposes but don’t want to have to keep changing the code each time (or keep going back through the drop-down menus)
- When you’re using a user-written graphing package that doesn’t have an option for what you’re trying to edit (or the option just isn’t working for whatever reason)
Regarding this last point, as an example, I love the -grc1leg- package (see my guide on bar graphs), but it doesn’t seem to recognize standard code for adjusting the graph dimensions and margin sizes. This means I need to use Graph Editor to adjust these aspects of my graph.
Yet despite its usefulness, jumping into Graph Editor can be intimidating, especially since there aren’t (to my knowledge) many concise guides dedicated to using GE.
On top of that, even seasoned Stata users are not aware of some of GE’s coolest tricks.
The goal of this guide is to help Stata users, from total beginners to longtime users, get more out of Graph Editor.
The guide proceeds in four Levels. It starts with more common tasks, like using GE to change global properties (see Level 1) and individual properties (Level 2), to more advanced tasks like creating and playing graph recordings (Level 3) and directly recovering/executing graph recording (.grec) code (Level 4).
Preliminaries
A couple quick things before we get started:
- Graphs will either use the “stcolor” scheme (new to Stata v.18), schemes from “schemepack” by Asjad Naqvi, or from “538 schemes” and “blindschemes” from Daniel Bischof. To install these, simply execute the following code:
ssc install schemepack, replace // install schemepack
ssc install g538schemes, replace // install 538 schemes
ssc install blindschemes, replace // install blindschemes
You can then explore all your awesome new schemes by executing the following:
graph query, schemes
2. All graphs use “AbelPro-Regular” font, which can be downloaded here. For details on installing/using fonts that are not native to Stata, see here.
Opening Graph Editor
Let’s load some data and make a quick graph:
#Load auto data
sysuse auto.dta, clear
# Make a scatterplot
scatter mpg headroom, /// main scatter command
scheme(538w) /// use 538w scheme
xlab(, glcolor(gs15) glpattern(solid)) /// add vertical solid gray lines
ylab(, glcolor(gs15) glpattern(solid)) /// add horizontal solid gray lines
mlabel(make) mlabsize(vsmall) // label each marker with small labels
We then get a graph with various cars’ headroom on the x-axis and miles-per-gallon on the y-axis. If you’ve ever wondered what this relationship looked like for cars manufactured in 1978, the wait is over:
In the image above, I’ve opened GE by clicking the “Graph Editor” icon in the top-right corner, indicated by the red arrow above (I’m using Stata 18 on a Mac, so it may look a bit different on a PC and/or earlier Stata versions).
The blue arrow in the lower left corner points to the cursor (“Select”) icon. Stata defaults to this icon when you open GE and it covers the vast majority of things you’d use GE for.
Note: To close GE, simply click the “Graph Editor” icon again (if you don’t wish to save the changes you made, simply click “Don’t save” when prompted).
Quick forewarning: Stata doesn’t crash often for me, but when it does, it’s almost always when I’m using GE. As such, make sure you save your files before jumping into GE.
Level 1: Changing Global Properties
A common use of GE is to change what are called “global properties.” That is, some aspect that applies to the whole graph. For example, the colors of all the markers in a scatterplot; the graph dimensions; the color and outline color of all the bars in a bar graph; the range and increments of an x-axis; the title of a graph or an axis; the background color of the plot; and so on.
Again, these are all things you’d change while having the “Select” icon selected.
Fortunately, changing global properties is really very easy. For this Level, double-clicking is the key.
Scatterplot Example
Let’s say we want to change the colors of the markers (i.e., the dots). Click on a marker — any marker — once and Stata will highlight them all with little red cursors.
If you double-click on a marker, Stata will open a nice menu box that will allow you change anything you like for the markers — colors, opacity (which involves how transparent the color is), size, shape, angle, etc.
As an example, I’ll change the markers to be medium-sized orange squares, at 75% opacity, with a thin magenta outline color. Here’s what we get:
You can also easily change anything having to with titles. For example, you can change the text of the x-axis title by double-clicking the title of the x-axis. In this example, you’d double-click “Headroom (in.)” (see the orange arrow below). You can also add or edit any of the other titles by double-clicking items in the pane on the right (see items in the orange oval):
Double-clicking on “xaxis1” within this pane, for example, brings up the “Axis properties” menu where you can edit the look of grid lines, add reference lines (vertical reference lines in this case, since we’re working with the x-axis), and — importantly — change the “Axis rule”.
For example, if you select “Range/Delta”, you can specify the minimum and maximum values on the x-axis, as well as the increments you want to use. In the example below, I’m setting the minimum value to 1, maximum value to 6, and change (delta)=.5:
Bar Graph Example
Let’s try another example with a bar graph. Here’s some code to create a quick bar graph:
# Create bar graph
graph hbar mpg, over(foreign) /// bar graph command to display means across groups
scheme(black_tableau) /// change scheme
ylab(, glcolor(gs6) glpattern(solid)) /// change look of vertical gridlines
blabel(bar, color(white) format(%3.0f) size(medsmall) pos(inside)) // format bar labels
If you double-click either of the bars, you will get a “Rectangle properties” drop-down menu. Using this menu you can change anything about the bars: their colors, opacity, outline color, width, style, etc.
We might also want to change the look of the labels that we added to the bars. Again, to do this, simply double-click on one of the labels. In the example below, I double-clicked on the “20” in the top bar of the graph, at which point a “Textbox properties” drop-down menu appeared. I then made the text “medium large” and yellow, then navigated to the “Box” tab (see blue arrow below), checked the “place box around text” box, filled the box with “Grayscale 1” color and specified Black outline color (notice how the bar labels now appear (example circled in orange)):
Coefplot Labels Example
I am a huge fan of using the user-written -coefplot- package for displaying regression model results (see my guide on -coefplot- here).
One common edit that needs to be done with -coefplot- graphs is adjusting the labels for the variables. This can of course be done with code (again, see my guide), but you can also do it pretty easily with GE.
First let’s run a regression model and then generate a coefplot:
# Install coefplot
ssc install coefplot, replace
# Run model
reg price mpg foreign
#Create coefplot
coefplot, drop(_cons) xline(0) scheme(plottig) ///
msize(large) ///
ciopts(lwidth(medthick)) ///
xlab(, glcolor(gs15) glpattern(solid)) ///
ylab(, glcolor(gs15) glpattern(solid)) ///
xtitle(Effect on Price (USD))
Let’s say we want to edit those labels on the left side. Again, just open GE and then double-click anywhere in that area of the graph. You’ll then see a fairly involved “Axis properties” drop-down menu — click the button that reads, “Edit or add individual ticks and labels”:
You’ll then be able to select and edit each label to your liking by simply highlighting the label and clicking “Edit”. For example, here I’ve edited both labels (which you can also see on the y-axis):
After editing the labels, simply click “Close”, then “OK” in the “Axis properties” menu, and you’re good to go.
Changing Graph Dimensions
Finally, it’s also easy to change graph dimensions. After opening GE, click once on the outer edge of the graph. Stata will highlight it in red. Then double-click the same spot. You’ll get a drop-down menu that allows you to adjust margins and also the graph size, among other things.
For example, in the “Aspect/Size” tab, you can change the “Y size” and “X size” to be whatever values you like (I tend to go with Y=4.5 inches and X=6.5 inches, personally):
Level 2: Changing Individual Properties
Whereas double-clicking was key in Level 1, right-clicking is key in Level 2. (On a laptop, it would simply be holding down “control” and then clicking.)
Our goal here is not to change global properties of the graph but, rather, properties that apply to specific individual objects in the graph (for example, a particular marker or marker label in a scatterplot; a particular bar in a bar graph, etc.).
Scatterplot Example
Let’s make the scatterplot from above again:
# Make a scatterplot
scatter mpg headroom, /// main scatter command
scheme(538w) /// use 538w scheme
xlab(, glcolor(gs15) glpattern(solid)) /// add vertical solid gray lines
ylab(, glcolor(gs15) glpattern(solid)) /// add horizontal solid gray lines
mlabel(make) mlabsize(vsmall) // label each marker with small labels
One thing that immediately makes this graph look very amateur is that the marker label all the way to the right is getting cut off (the label extends beyond the plot region). It should say “Plym. Volare”, but all we can see is “Plym”.
There are a few ways we could deal with this. For example, we could increase the plot region margin size, but this might make the graph look a little weird and extra cluttered. We could change all the markers globally to be “9 o’clock” instead of the default “3 o’clock”, but for other data this might just end up making other marker labels get cut off.
A better way is to only adjust this individual label. But how?
Warning: this process can be surprisingly clunky sometimes. Take deep breaths. It’ll work…eventually.
Follow these steps:
- Click once on all of the labels so that they all have the little red cursors on them
- Now, hover your cursor right over the label you want to adjust, then right-click
- If it worked, you should see a box appear with the option “Observation properties”. If you don’t see this, repeat steps 1 & 2, but try right-clicking on a slightly different spot of the marker label. Pro tip: sometimes, you just need to click on something completely different (e.g., double-click on the y-axis title, then cancel out of it) and then try steps 1 and 2 again. (Clunky indeed, I know.)
Once you see this drop-down menu appear (again, look for “Observation properties”), you’re on your way:
From there, simply click on “Observation properties” (not “Marker label properties”!) and adjust the position of the label to your liking (e.g., “9 o’clock” will move just this particular label to the opposite side of the marker).
Using the same right-clicking process, you can also edit individual markers. Again, you’d just first click once to highlight all the markers, and then right-click on the particular marker you want to edit.
For example, after changing the “Plym. Volare” label’s position, I might want to draw a reader’s attention to the “VW Diesel” marker at the top by making the marker larger and red, with a black outline, and making the marker label red as well. Using right-clicking, here’s what we get (notice the red “VW Diesel” marker at the top):
Bar Graph Example
Changing individual properties is basically the same procedure for bar graphs. For example, let’s run the following code:
#Bar graph
graph bar, over(rep78) ///
scheme(stcolor) ///
ylab(, glcolor(gs15) glpattern(solid)) ///
ytitle(Percent of Cars in Each Repair Category) ///
b1title(Repair Category of Vehicle) /// *trick for adding title to x-axis in a bar graph
blabel(bar, color(white) format(%3.0f) size(medsmall) pos(inside)) // format bar labels
This generates a graph with five vertical bars, each representing a repair category of our cars. Let’s say we really wanted to highlight the bar representing repair category #4. Simply do the following steps:
- Click once on bar #4
- Now right-click on the bar, which will make a drop-down menu appear
- At the bottom of that menu should be an option for “Object-specific properties”. Click on it and change anything you like about bar #4 (all other bars will be left intact!)
As an example, here I changed the color and outline color of bar #4:
Next is an example where even experienced users will probably need to use GE.
For some reason, Stata does not currently have code to change the appearance of individual bar labels. This can be a problem if, for example, one bar having a lighter color makes it difficult to read the label for that particular bar.
Fortunately, we can edit individual bar labels with GE! For example, let’s make another bar graph, this time a “stacked” bar graph (see my guide on “stacked” bar graphs here):
# Stacked bar graph
graph hbar, over(rep78) over(foreign) ///
scheme(white_viridis) ///
asyvar stack percentage ///
bar(1, fcolor(%80) lcolor(none)) ///
bar(2, fcolor(%80) lcolor(none)) ///
bar(3, fcolor(%80) lcolor(none)) ///
bar(4, fcolor(%80) lcolor(none)) ///
bar(5, fcolor(%80) lcolor(none)) ///
ylab(, glcolor(gs15) glpattern(solid)) ///
ytitle(Percent of Cars in Each Repair Category) ///
legend(title(Repair Category, box fcolor(black) color(white) size(small))) ///
legend(pos(3) col(1)) ///
blabel(bar, color(white) format(%3.0f) size(medsmall) pos(center)) // format bar labels
The problem with this graph is that the “4” in the yellow portion of the top bar is a bit difficult to read because it is white text on yellow. Since the rest of the bar labels look pretty good in white, we can simply change the color of this “4” using GE:
- Click once on the “4”. Stata will then place a red square around it
- Right-click on the “4” and make sure the “Object-specific properties” option appears. (Again, this might take a few attempts.)
- Click on “Object-specific properties” and change the color of the text to something darker (e.g., “gs8”)
After making this change myself, I also opted to make the labels on the left vertical instead of horizontal (double-click in the area with the labels on the left, then go to “Label properties” (under “Global properties”), then change “Angle” to “vertical”). We get the following graph (notice the darker “4” in the yellow portion):
Tip: After you’ve edited an individual item by right-clicking, you can do further edits on just that item by double-clicking it. For example, if we change our mind and want to try a different color for the “4”, we can now just double-click on it to make additional changes.
Level 3: Using Graph Editor with Graph Record
After you start making lots of edits to your graph, a certain kind of dread might set in: what if, for some reason or another, you had to re-do all of these edits? For example, maybe you get additional data; you realize a mistake in your model; you are making a bunch of very similar graphs and you need to make the same edits to every one of them; and/or, you just accidentally delete or forget to save the graph file. How can you re-do everything to match how you did it the first time?
In a similar vein, imagine you’re collaborating with someone on a project, or have to provide your code for replication purposes. How can someone else possibly replicate all of the changes you manually made to your graph?
Answer: you need to learn the almighty Graph Record feature.
What is Graph Record?
You may have noticed each time you open Graph Editor, there are a few strange buttons in one corner:
In the image above, the one on the left is the “Record” button, while the one on the right is the “Play” button. (The middle button is “pause,” which I never really use, personally.)
What do these buttons do? Essentially, they enable you to record every single change you make to your graph while using Graph Editor.
Why would we want to do that? Because once you have a recording of all your edits, you are now able to instantly re-do every single one of your edits.
It doesn’t matter if you had Graph Editor open for an hour and made 1000 changes to your graph. Once you have this recording, you are able to execute all of your edits instantaneously. 🙌
This makes it super easy to keep track of your edits, re-do all of your edits, apply the same set of edits to a bunch of different graphs, and enable others to easily replicate your edits. It’s really pretty awesome.
Here is an overview of the steps to do it:
- Make a graph and open GE
- Press the “Record” button
- Make all the changes you want
- Hit the “Record” button again, which will stop the recording. Stata will now have a graph recording (.grec) file created for you that it wants you to save
- Select “Browse” and place the file somewhere convenient
- Play that recording on the next graph for which you want those same edits
Scatterplot Example
Let’s make a scatterplot with the following code:
# Make a scatterplot
scatter mpg headroom, ///
scheme(538w) ///
xlab(, glcolor(gs15) glpattern(solid)) ///
ylab(, glcolor(gs15) glpattern(solid)) ///
msize(medium) ///
mcolor(stgreen%80) mlcolor(stblue) ///
mlabel(make) mlabcolor(black) mlabsize(tiny)
Let’s say we want to edit that “VW Diesel” observation again. After opening GE, we immediately press “Record”.
Next, using the right-clicking method described in Level 2, let’s again make the VW Diesel marker a bit larger, red, and have a black outline. We’ll also make the label red, and then again fix that same “Plym. Volare” marker label that gets cut off.
Now press “Record” again. You will now be prompted to name your recording. After doing so, my strong advice is to select “Browse” and save the recording somewhere you can easily find it (e.g., in the same folder as your .dta file, or even just on your desktop):
The recording is then saved as a “.grec” file. The crucial next step is to make sure that your Working Directory is changed to wherever this .grec file is located. You can easily navigate to it by going to File > Change working directory… Then navigate to where the file is and select “Choose”. (Tip: after doing this, Stata will give you the code (in the Results window) to change to this working directory, which you can then put in your .do file, if applicable.)
Now here’s the fun part. Let’s say I lost my original graph and needed to make all these edits again, or say that a colleague wanted to replicate my edits. With my .grec file saved under the name “scatterplotfix_VW”, take a look at the last line of code below:
# Make the graph with an option to play the recorded .grec file
# Remember to first set your working directory to where the .grec file is located!
scatter mpg headroom, ///
scheme(538w) ///
xlab(, glcolor(gs15) glpattern(solid)) ///
ylab(, glcolor(gs15) glpattern(solid)) ///
msize(medium) ///
mcolor(stgreen%80) mlcolor(stblue) ///
mlabel(make) mlabcolor(black) mlabsize(tiny) ///
play(scatterplotfix_VW)
That last line of code — the “play( )” option — will play our saved recording. That is, it will create the graph and then execute every single edit we recorded. Here’s what we get from the code above, and without ever opening Graph Editor:
Pretty cool, right?
Important: In the event that graph code doesn’t allow you go play the recording (e.g., some user-written packages don’t allow the “play( )” option), there’s an easy fix: just use the -graph play ( )- command on a separate line.
Specifically, after creating the graph, simply run one additional line of code while the graph is still open. For example, below are two different sets of code (the graph code and then code to play the .grec file), but you can run them all at once and get the same result as above:
# Play the graph as a separate line of code, not as an option
#Make the graph
scatter mpg headroom, ///
scheme(538w) ///
xlab(, glcolor(gs15) glpattern(solid)) ///
ylab(, glcolor(gs15) glpattern(solid)) ///
msize(medium) ///
mcolor(stgreen%80) mlcolor(stblue) ///
mlabel(make) mlabcolor(black) mlabsize(tiny) //
#Run this while graph is still open
graph play "scatterplotfix_VW"
Here’s another scatterplot example. Overlapping marker labels in a scatterplot are…not great. It makes graphs look messy and, again, pretty amateur. So, I spent a few minutes manually editing (with the right-click technique described above) every single marker label that overlapped. Tedious, yes, but improves the graph quite a bit.
Now, because I recorded these edits (saved as “scatterplotlabelfixes.grec”), I can quickly recreate the edited graph from scratch by simply executing the following:
# Recording of fixes to ever single marker label
scatter mpg headroom, ///
scheme(538w) ///
xlab(, glcolor(gs15) glpattern(solid)) ///
ylab(, glcolor(gs15) glpattern(solid)) ///
msize(medium) ///
mcolor(stgreen%80) mlcolor(stblue) ///
mlabel(make) mlabcolor(black) mlabsize(tiny) ///
play(scatterplotlabelfixes)
This code creates the following graph, free of overlapping marker labels:
Bar Graph Example
Let’s run some code for a bar graph:
# Make a bar graph
graph bar, over(rep78) over(foreign) ///
scheme(white_jet) ///
asyvar ///
ylab(, glcolor(gs15) glpattern(solid)) ///
legend(title(Repair Category, box fcolor(black) color(white) size(small))) ///
legend(pos(3) col(1)) ///
blabel(bar, color(white) format(%3.0f) size(medsmall) pos(center)) // format bar labels
Let’s say I again want to make the labels a little darker for the lightest-colored bars, as well as add some text and an arrow to the graph.
Text can be added by clicking on “T” icon in the corner (see orange arrow in image below). An arrow can be added by clicking on the “ \ ” icon (see purple arrow in image below).
To add text, once you’ve clicked on the text option, simply double-click the exact spot in the graph where you want the text to go. You’ll then be given a drop-down menu with all sorts of options for the text (options for colors, sizes, width, whether you want a box around the text, the fill color of the box, etc.). (Note: like most other things, text can of course also be added using code — see my post here for an example.)
To add an arrow (or just a line), once you’ve clicked the “ \ ” icon, you simply use your mouse to draw where you want the arrow to go (click and hold, then start dragging).
Important: Once you’ve added your text or your arrow, if you want to make further changes to them, you need to go back to the “Select” icon. After that, double-click on your text or arrow to make whatever changes you want.
For example, here’s the menu I get when I double-click on the red arrow I added into the plot region:
As before, I saved the recording of all the edits I made, allowing me to keep track of them and then reproduce them instantaneously by simply running the following code (again, note the “play” option in the last line of code):
# Using the "play" option
graph bar, over(rep78) over(foreign) ///
scheme(white_jet) ///
asyvar ///
ylab(, glcolor(gs15) glpattern(solid)) ///
legend(title(Repair Category, box fcolor(black) color(white) size(small))) ///
legend(pos(3) col(1)) ///
blabel(bar, color(white) format(%3.0f) size(medsmall) pos(center)) /// format bar labels
play(bargraphedits.grec)
We get the following graph (again, without ever even opening Graph Editor):
What if I make a recording, but then realize I need to make some more edits?
You can make AND play multiple recordings! 😁
You’ll just need to use the separate -graph play- command (discussed above), rather than the “play( )” option, for each additional recording. Using the -graph play- command for each recording, you can play as many recordings as you want.
Level 4: Retrieving & Running Graph Record Code
I am often asked by my students, “Is there any way to get the code for the edits that we made with Graph Editor?”
For a long time, my answer was: “That would be great but, unfortunately, no.” When we make graphs using drop-down menus, an amazingly helpful feature of Stata is that it doesn’t just produce the graph — it also gives us, in the Results window, the exact code to make that graph (I constantly take advantage of this feature to learn syntax for different options!).
However, with GE, we get no such code in the Results window. We just get a .grec file (assuming we recorded our edits, of course).
But it turns out my response to students wasn’t quite right. We can, in fact, retrieve and run code for the changes we made with Graph Editor. 🤯
The key caveat is that the code is not the normal Stata syntax. As such, it can be a bit messy to sift through, depending on how many edits we made.
But nevertheless, I’m here to tell you it can be done. Here’s how…
Scatterplot Example with Cut-off Marker Label
Let’s repeat the example from above where the “Plym. Volare” marker label gets partially cut off.
I open GE, press “Record”, change this individual marker label from the 3 o’clock position to the 9 o’clock position, stop recording and then save my .grec file.
I then go and actually open up my .grec file (simply double-click on the file). At first glance, this file appears to be absolute gobbledy-gook:
Yet it turns out that any lines starting with a “.” (for example, things like “.plotregion” or “.style” or “.title.text”) are pieces of code that we can actually execute in a .do file!
In the example below, the orange arrow is pointing to a line we can copy and paste into our .do file:
And, if you actually look carefully at this line of code, you can indeed see that at the end of it, it reads “label(position(9)))” which is exactly the change I made!
Now here’s the key for running this line of code after you copy it and paste it into your .do file: you need to precede it with “gr_edit”, which remains an undocumented (and thus still quite mysterious) Stata command.
Let’s put it all together, shall we?
#Generate the graph
scatter mpg headroom, ///
scheme(538w) ///
xlab(, glcolor(gs15) glpattern(solid)) ///
ylab(, glcolor(gs15) glpattern(solid)) ///
mlabel(make) mlabsize(vsmall)
# While the graph is open, run the Graph Editor code
gr_edit .plotregion1.plot1.EditCustomStyle , j(46) style(label(position(9)))
Notice in the code above: the graphing code is run and then, while the graph is still open, we run the line of code that starts with “gr_edit”. (Yes, you can run the graph and .grec code all at once.)
We then get the following:
Success! Using just the code from the .grec file, and without ever playing the graph recording, we have moved the label to the 9 o’clock position from the 3 o’clock position.
Why bother with the .grec code? Can’t we just play the recordings?
Answer: absolutely.
However, if there’s a part of you that would prefer to use all code, and/or doesn’t want to have to keep track of a separate .grec file in order to make your graph, then using .grec code is a nice option, especially when it’s just one or two small edits (thus requiring fairly little effort to retrieve and run the code).
For example, I really like using the .grec code when I want to make an individual bar graph label lighter or darker (as we did above). It seems a bit excessive to need a whole recording for one simple change to a bar label, so I personally like to just add one line of .grec code rather than have to play a recording.
This practice also makes it very easy to share code with others who don’t have the recording. By using .grec code, in other words, they don’t even need the recording.
Last Graph!
To demonstrate how we can use lots of .grec code all at once, here I’m going to create a scatterplot with a LOWESS fit line. After running the graphing code, I used GE to edit the legend and add some text within a text box. I saved the .grec file, opened it, and then copied all of the lines of code that started with a “.” and pasted them into my .do file immediately after the regular graphing code. Finally, I placed “gr_edit” before each of these lines, like so:
#Make the graph
scatter price mpg, jitter(10) ///
scheme(538w) ///
mcolor(%90) msize(medium) mlcolor(lime) ///
xlab(, glcolor(gs15) glpattern(solid)) ///
ylab(, glcolor(gs15) glpattern(solid)) ///
legend(pos(6) col(2)) ///
|| lowess price mpg, lcolor(stblue) //
# Run the .grec code
gr_edit .legend.plotregion1.label[2].text = {}
gr_edit .legend.plotregion1.label[2].text.Arrpush LOWESS Fit Line
gr_edit .plotregion1.AddTextBox added_text editor 13322.2398443236 30.24054634751399
gr_edit .plotregion1.added_text_new = 1
gr_edit .plotregion1.added_text_rec = 1
gr_edit .plotregion1.added_text[1].style.editstyle angle(default) size( sztype(relative) val(3.4722) allow_pct(1)) color(black) horizontal(left) vertical(middle) margin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) linegap( sztype(relative) val(0) allow_pct(1)) drawbox(no) boxmargin( gleft( sztype(relative) val(0) allow_pct(1)) gright( sztype(relative) val(0) allow_pct(1)) gtop( sztype(relative) val(0) allow_pct(1)) gbottom( sztype(relative) val(0) allow_pct(1))) fillcolor(black) linestyle( width( sztype(relative) val(.2) allow_pct(1)) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .plotregion1.added_text[1].style.editstyle size(medlarge) editcopy
gr_edit .plotregion1.added_text[1].text = {}
gr_edit .plotregion1.added_text[1].text.Arrpush Graph Editor is cool! 😊
gr_edit .plotregion1.added_text[1].style.editstyle color(white) editcopy
gr_edit .plotregion1.added_text[1].style.editstyle drawbox(yes) editcopy
The syntax is definitely strange looking, but when I run all of this code at once, I get the following graph:
Success!!! Notice: no need to even play the graph recording anymore. Just. Pure. Code.
Conclusion
I sincerely hope this guide has been helpful for you. It has taken me lots, and lots, and lots of trial and (especially) error over the years, but learning Graph Editor has helped me enormously in my own work and in my teaching, so I hope that this guide can benefit you as well. Enjoy!
About the Author
John V. Kane is Clinical Associate Professor at the Center for Global Affairs and an Affiliated Faculty member of NYU’s Department of Politics. He received his Ph.D. in political science and his primary research interests include public opinion, political psychology, and experimental research methodology. His research has been published in a variety of top-ranking peer-reviewed journals, including the American Political Science Review, American Journal of Political Science, the Journal of Politics, and the Journal of Experimental Political Science. His research has been featured in numerous media outlets, including The New York Times, The Washington Post, and National Public Radio. He has taught graduate courses on political psychology, research methods, statistics and data analysis, and has also received teaching excellence awards from both New York University and Stony Brook University. His website is www.johnvkane.com. You can follow him on X/Twitter, ResearchGate, LinkedIn, and/or BlueSky Social.