Stata Tidbits

These tidbits contain bits and pieces of information I hope you find helpful to use Stata more effectively. You can receive notifications of new tidbits as they are added (via email) by clicking on the subscribe box at the left. (Every email has an unsubscribe link, making it a snap to unsubscribe.)
« Setting the scrollbufsize | Graph symbols and fonts in Stata 11: Part 1 »

Graph symbols and fonts in Stata 11: Part 2

As we saw last week, Stata 11 can display graphs using the full Greek alphabet (upper and lower case), math symbols, as well as boldface and italics. This week we will illustrate how to display text using different fonts. Consider this basic graph below which includes a title.

. use allstates, clear
(Data on 50 States)

. graph twoway (scatter propval100 popk) (lfit propval100 popk), ///
> title(Property values by population)

The title is displayed using a sans serif font. Let's instead display the title using a serif font.

. scatter propval100 popk, ///
> title({stSerif:This is the title in a serif font})

We can even mix up serif and sans serif fonts within the title, as shown below.

. scatter propval100 popk, ///
> title(This part {stSerif:is in a serif font} {stSans:and now back to sans serif})

You can also specify a monospaced font and a symbol font. Below, the title is shown in a serif font, the subtitle in a sans serif font, the caption in a monospace font, and the note is in a symbol font. The symbol font displays greek letters

. scatter propval100 popk, ///
> title("{stSerif:This is the title in a serif font}") ///
> subtitle("{stSans:This is the subtitle in a sans serif font}") ///
> caption("{stMono:This is the caption in a monospace font}") ///
> note("{stSymbol:ABCDEFG abcdefg}")

So far, all of these fonts are general fonts that are available on all platforms. You can specifically refer to fonts that are available on your platform, on your particular computer. For example, I am using Windows and I have a font named Gigi on my computer (and you may have it too). Below I specify that the title should be displayed using this font.

. scatter propval100 popk, ///
> title({fontface Gigi:This is the title in Gigi})

In fact, I am going to go crazy in the example below and display the title in Gigi, the subtitle using the Papyrus font, the caption using the Parchment font, and the note using the Pristina font. Note how I am able to use the size() option to increase the size of text, even when using these custom fonts.

. scatter propval100 popk, ///
> title({fontface Gigi:This is the title in Gigi}) ///
> subtitle({fontface Papyrus:This is the subtitle in Papyrus}) ///
> caption({fontface Parchment:This is the caption in Parchment}, size(vhuge)) ///
> note({fontface Pristina:This is the note in Pristina}, size(large))

Below I mix the standard font, the Papyrus font, and the Gigi font all within the subtitle.

. scatter propval100 popk, ///
> subtitle(This is {fontface Papyrus:a very} crazy {fontface Gigi:subtitle})

Sometimes, the name of a font contains a space within it. For example, I have a font on my computer named Elephant Italic. In order to specify this font, I need to enclose the name within double quotes, as shown below. Because this introduces a double quotation within the title option, the title is surrounded by compound quotes, i.e., the title begins with `" and ends with "' (see help quotes).

. scatter propval100 popk, ///
> title(`"{fontface "Elephant Italic":This is the title in Elephant Italic}"')

Finally, how did I discover which fonts I have on my computer? I went to Control Panel and then I selected Fonts. That lists the different fonts that are available on my computer. The image below shows a portion of the fonts listed.

The highlighted font is Elephant Italic. Note that when I referenced it, I did not included the words (TrueType). This is not part of the font name, but instead describes the type of font (that it is a TrueType font).

This concludes this tidbit for this week. For more information, you can see help graph text.

You can download the example data files from this tidbit (as well as all of the other tidbits) as shown below. These will download all of the example data files into the current folder on your computer. (If you have done this before, then you may need to specify net get stowdata, replace to overwrite the existing files.

net from
net get stowdata

If you have thoughts on this Stata Tidbit of the Week, you can post a comment. You can also send me an email at MichaelNormanMitchell and then the at sign and gmail dot com. If you are receiving this tidbit via email, you can find the web version at .


PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.
Editor Permission Required
You must have editing permission for this entry in order to post comments.