This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / The Mathematica Book / Principles of Mathematica / The Structure of Graphics and Sound  /

2.9.15 Formats for Text in Graphics

Specifying formats for text in graphics.

  • Here is a plot with default settings for all formats.
  • In[1]:= Plot[Sin[x]^2, {x, 0, 2 Pi}, PlotLabel->Sin[x]^2]


  • Here is the same plot, but now using a 7-point italic font.
  • In[2]:= Plot[Sin[x]^2, {x, 0, 2 Pi}, PlotLabel->Sin[x]^2,
    TextStyle->{FontSlant->"Italic", FontSize->7}]


  • This uses TraditionalForm rather than StandardForm.
  • In[3]:= Plot[Sin[x]^2, {x, 0, 2 Pi}, PlotLabel->Sin[x]^2,
    FormatType -> TraditionalForm]


  • This tells Mathematica what default text style to use for all subsequent plots.
  • In[4]:= $TextStyle = {FontFamily -> "Times", FontSize -> 7}


  • Now all the text is in 7-point Times font.
  • In[5]:= Plot[Sin[x]^2, {x, 0, 2 Pi}, PlotLabel->Sin[x]^2]


    Typical elements used in the setting for TextStyle or $TextStyle.

    If you use the standard notebook front end for Mathematica, then you can set $TextStyle or TextStyle to be the name of a cell style in your current notebook. This tells Mathematica to use that cell style as the default for formatting any text that appears in graphics.
    You can also explicitly specify how text should be formatted by using options such as FontSize and FontFamily. Note that FontSize gives the absolute size of the font to use, measured in units of printer's points, with one point being inches. If you resize a plot, the text in it will not by default change size: to get text of a different size you must explicitly specify a new value for the FontSize 


    Changing the formats of individual pieces of output.

  • This outputs the plot label using the section heading style in your current notebook.
  • In[6]:= Plot[Sin[x]^2, {x, 0, 2 Pi},
    PlotLabel->StyleForm[Sin[x]^2, "Section"]]


  • This uses the section heading style, but modified to be in italics.
  • In[7]:= Plot[Sin[x]^2, {x, 0, 2 Pi},
    PlotLabel->StyleForm[Sin[x]^2, "Section",


  • This produces TraditionalForm output, with a 12-point font.
  • In[8]:= Plot[Sin[x]^2, {x, 0, 2 Pi},


    You should realize that the ability to refer to cell styles such as "Section" depends on using the standard Mathematica notebook front end. Even if you are just using a text-based interface to Mathematica, however, you can still specify formatting of text in graphics using options such as FontSize. The complete collection of options that you can use is given in Section 2.10.10.