Formats for Text in Graphics

Specifying formats for text in graphics.

Here is a plot with default settings for all formats:

Plot[Sin[x]^2,{x,0,2 Pi},PlotLabel->Sin[x]^2]

Here is the same plot, but now using a 12-point bold font:

Plot[Sin[x]^2,{x,0,2 Pi},PlotLabel->Sin[x]^2,BaseStyle->{FontWeight->"Bold",FontSize->12}]

This uses (RefLink[StandardForm, paclet:ref/StandardForm]) rather than (RefLink[TraditionalForm, paclet:ref/TraditionalForm]):

Plot[Sin[x]^2,{x,0,2 Pi},PlotLabel->Sin[x]^2,FormatType->StandardForm]

This tells the Wolfram Language what default text style to use for all subsequent plots:

SetOptions[Plot,BaseStyle->{FontFamily->"Times",FontSize->14}];

Now all the text is in 14-point Times font:

Plot[Sin[x]^2,{x,0,2 Pi},PlotLabel->Sin[x]^2]

Typical elements used in the setting for (RefLink[BaseStyle, paclet:ref/BaseStyle]).

If you use the standard notebook front end for the Wolfram Language, then you can set (RefLink[BaseStyle, paclet:ref/BaseStyle]) to be the name of a style defined in your current notebook's stylesheet. You can also explicitly specify how text should be formatted by using options such as (RefLink[FontSize, paclet:ref/FontSize]) and (RefLink[FontFamily, paclet:ref/FontFamily]). Note that (RefLink[FontSize, paclet:ref/FontSize]) gives the absolute size of the font to use, measured in units of printer’s points, with one point being (1/72) inches. If you resize a plot whose font size is specified as a number, 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 (RefLink[FontSize, paclet:ref/FontSize]) option. If you resize a plot whose font size is specified as a scaled quantity, the font will scale as the plot is resized. With (RefLink[FontSize, paclet:ref/FontSize])->(RefLink[Scaled, paclet:ref/Scaled])[s], the effective font size will be s scaled units in the plot.

Now all the text resizes as the plot is resized:

Plot[Sin[x]^2,{x,0,2 Pi},BaseStyle->{FontSize->Scaled[.05]}]

Changing the formats of individual pieces of output.

This outputs the plot label using the section heading style in your current notebook:

Plot[Sin[x]^2,{x,0,2 Pi},PlotLabel->Style[Sin[x]^2,"Section"]]

This uses the section heading style, but modified to be in italics:

Plot[Sin[x]^2,{x,0,2 Pi},PlotLabel->Style[Sin[x]^2,"Section",FontSlant->"Italic"]]

This produces (RefLink[StandardForm, paclet:ref/StandardForm]) output, with a 12-point font:

Plot[Sin[x]^2,{x,0,2 Pi},PlotLabel->Style[StandardForm[Sin[x]^2],FontSize->12]]

You should realize that the ability to refer to styles such as "Section" depends on using the standard Wolfram Language notebook front end. Even if you are just using a text-based interface to the Wolfram Language, however, you can still specify formatting of text in graphics using options such as (RefLink[FontSize, paclet:ref/FontSize]). The complete collection of options that you can use is given in "Text and Font Options".