Writing Greek letters and other symbols in graphs


Greek letters, math symbols, and other symbols (such as Copyright and Trademark symbols) can be incorporated in Stata graphs with the use of SMCL tags. SMCL (Stata Markup and Control Language; pronounced as “smickle”) is used to modify all text output in Stata.

The tag for Greek letters or symbols are of the form {&name}. To illustrate, we will use auto.dta:


#delimit ;

sysuse auto;  /* see note below */

sum price, meanonly;
local p=r(mean);
sum mpg, meanonly;
local m=r(mean);

tw scatter price mpg, xline(m') yline(p’) note(“The verical and horizontal lines correspond” “to {&mu}{subscript:mpg} and {bf:{&mu}{subscript:price}}, respectively.”, pos(2) ring(0)) size(vlarge);

#delimit cr




{&mu} –> lower case Greek letter mu
{subscript:mpg} –> display mpg as a subscript
{bf:{&mu}{subscript:price}} –> display mu with subscript price as bold

For the complete list of symbols, type: “help graph_text”.

Note: -sysuse- is used to to load example datasets that are installed with Stata. To list all data  installed with Stata, type: “sysuse dir”.

6 Responses

  1. Thanks for this post. When I enter

    {bf:{&mu}{subscript:price}},

    neither the \mu nor the subscript are bolded. However, when I enter

    {bf:text{&mu}{subscript:price}},

    the word “text” is bolded. This is generally a problem when I’m trying to have the font style apply to other things within the bracket but are bracketed themselves. For example, I’m trying to italize k_i, but when I type

    {it:k{subscript:i}},

    only “k” is italicized.

    Do you have any suggestions?

  2. How do I invoke colored text options using the same scml language. I have some added graph text that I wish to apply multiple colors to correspond to to plotted lines.

  3. How do I create letters or variables with “hats”. How do I do what in LateX would be \hat{\pi} ?
    Any idea?
    Max

    • Hi Max! Did you ever figure this out? I’m trying to plot a graph with beta hat coefficients on the x axis, but cannot find a symbol for the hat!

  4. […] [Note: For more text in graph options (e.g. bold, Greek letters, font type), see -help graph text-. See also Writing Greek letters and other symbols in graphs.] […]

Leave a Reply