Producing an Infographic in Stata

An infographic uses pictures, occasionally with some words, to convey a piece of information. You can make infographics in Stata by utilising special fonts. These fonts have images that are assigned to letter characters, so for example when you put an “A” in the font you will see a picture of a car. Many different fonts are available for free through different font websites. You can also create your own if you know how.

Here I am going to create an infographic using the Stata example dataset nlsw88.dta. This dataset contains an excerpt from the 1988 National Longitudinal Survey of Young Women and Mature Women (NLSW). I will use the font Mixed Bag 2 from You can download this font to follow along here: Make sure to open and install the font before continuing.

How to Use:

To attach a font in Stata you use a macro. The set up of the macro is as follows:

`”{fontface “font name”:chosen_character(s)}”’

In order to have these show on a graph you can either add this in a text box using the graph editor, or you can create a value label that uses the above format to label values with the chosen font. In this example I use text boxes.

Worked Example:

In this example I am going to create the following bar graph:

To do this, I first need to calculate the average wage of graduates versus those without a degree. I do this with the following commands:

Now I have the averages, time to create the graph. In the command pane:

This produces the following graph:

I am now going to edit this graph using the graph editor. I click on the graph editor icon, shown below:

This button is located in the toolbar, click on it to start the graph editor. I am also going to record the changes I make by clicking the record button, shown below:

This button will be greyed out until you start the graph editor.

I am now ready to start with the edits. I am going to navigate using the right-side menu, shown below:

I want a white background, so I double-click on the “Graph” object in the right-side menu (shown above). A pop-up box appears, and I change the color from “Light bluish gray” to “white”. Then click OK.

I also want to remove the legend, as my icons are going to provide this information. I double-click on the “legend” object in the right-side menu and a pop-up box appears. I select the “Advanced” tab of the box and tick the “Hide legend” tick box. I click OK to apply the change.

Now I want to change the bar colours. I click the “+” next to “bar region” in the right-side menu then double-click on bars[1] to change nograd_wage and bars[2] to change grad_wage. I change the colour of the nograd_wage bar to pink, and I change the colour of the grad_wage bar to lavender. I click OK in each box to apply the change.

I want to add my icons to the top of each bar, however there is currently not enough room above the lavender bar. To fix this I am going to extend the Y-axis range from 10 to 14. I double-click on “scaleaxis” in the right-side menu. At the top under “Axis rule” I select “Range/Delta” and I input 0 into the “Minimum” box, 14 into the “Maximum” box, and 2 into the “Delta” box. I click OK to apply.

I have reduced the size of my bars enough that I can now add the icons. To do this, I click the large “T” button on the left-side of the graph editor, shown below.

This allows me to add text boxes. I click on the space above the pink bar to add my first icon. I fill out the text box as you can see below, with the following macro:

`”{fontface “Mixed Bag 2”:J}”’

I click OK to apply the change. Next I click on the space above the lavender bar to add my second icon. I fill out the text box pop-up as you can see below, with the following macro:

`”{fontface “Mixed Bag 2”:F}”’

My graph now looks like this:

To reposition my icons, I click on the mouse-pointer icon (above the “T” icon) in the left-side menu to switch from text mode back to interact mode. I can now click and drag my icons to sit where I want them to. Once I am happy with this, I click the record button again to stop the recording. There is a pop-up box that appears asking to save the recording. Make sure to save using the “Browse…” button to make it easier to find your recording later. Once I have saved the recording I press the graph editor button again to exit the graph editor. This prompts me to save the graph.

This is one of many examples in which Stata's graph editor can be used to create powerful informative graphs.

733 views0 comments

Recent Posts

See All