top of page

Making an Infographic in Stata - Part 2

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 a series of infographics 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. I will demonstrate how to do both of these.

Worked Example:

In this example I am going to create the following graphic:

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:

egen grad_wage = mean(wage) if collgrad == 1
egen nograd_wage = mean(wage) if collgrad == 0
quietly summarize grad_wage
global gwage = round(r(mean),0.01)
quietly summarize nograd_wage
global nogwage = round(r(mean), 0.01)

Now I have the averages, time to create the graph. For this graphic I am creating a base graph simply to open the graph editor. No part of the initial graph appears in the final graphic. In the command pane:

scatter wage age

This produces the following graph:

I am now going to edit this graph using the graph editor. I click on the graph editor icon

in the toolbar to start the graph editor. I am also going to record the changes I make by clicking the record button

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

I want to hide the "plotregion1", "yaxis1", and "xaxis1" elements. You can access these by double-clicking on them directly, but for this graph I find it easier to use the right-side menu of the graph editor. To make the changes, double-click on "plotregion1", which produces a pop-up menu. Then click on the "Advanced" tab, and select the tick box "Hide plot region". Then click OK.

The steps are similar for "yaxis1" and "xaxis1", except the "Advanced" menu is a button at the bottom of the initial axis menu. For the "yaxis1", double click on "yaxis1", click on the "Advanced" button, then select the tick box "Hide Axis". Then click OK for both boxes to apply the change. Follow these exact steps for "xaxis1" as well.

I now have a blank graph that looks like this:

I now want to change the background colour, which is now all a bluish-grey tinge, to be plain white. To do this, double-click on "Graph" in the right-side menu, and change the "Color:" drop-down box to "White".

Now I have a totally blank canvas to make my infographic.

The rest of this graphci is made using text boxes. In the left panel of the graph editor is a small menu with symbols, as you can see in the above image. To add text boxes to our canvas, simply select the "T" symbol, underneath the mouse pointer, and click on the graph where you would like the text box to go. This pulls up a menu box where you put the information to go into the text box. For our first box, click roughly in the middle on the left side and enter the following text into the text box:

`"{fontface "Mixed Bag 2":J}"'

Also change the colour to "pink", and the size to "Half". Click OK when finished. The text box menu is shown below, as well as the graph after it is applied:

Please be aware that while the "T" symbol is active, clicking anywhere in the graph will just bring up another text box menu. To move our picture around, we need to first click back onto the mouse-pointer symbol in the left-side menu. Once the mouse-pointer is selected again, we can then drag our image/text box around the screen to reposition it. I move this first image over to the left.

Follow the same steps to add the other image to the graph. Click on the "T" symbol, click into the graph, and enter the following text:

`"{fontface "Mixed Bag 2":F}"'

I am colouring this one "lavender", the size is again "Half". I then position the image on the other side.

Now we use the wage averages we prepared earlier. Create two more text boxes, one with the text "$$gwage" under the graduate image, and another with the text "$$nogwage" under the other image. Use the "Tenth" size for these and leave the colour black.

The graph now looks like this:

And finally, we add a title. To do this, double-click on the "title" option in the right-side menu.

And now we have our finished product:

If you can find a font with the symbols in it you need, you can make any infographic. The Stata graph editor is an extremely robust graphics tool.

146 views1 comment

Recent Posts

See All
bottom of page