Credits Overview Plotting Styles Commands Terminals

Enhanced text mode

Many terminal types support an enhanced text mode in which additional formatting information can be embedded in the text string. For example, "x^2" will write x-squared as we are used to seeing it, with a superscript 2. This mode is selected by default when you set the terminal, but may be toggled afterward using "set termoption [no]enhanced", or disabled for individual strings as in set label "x_2" noenhanced.

Note: For output to TeX-based terminals (e.g. cairolatex, pict2e, pslatex, tikz) all text strings should instead use TeX/LaTeX syntax. See latex.

Control Examples Explanation
^ a^x superscript
_ a_x subscript
@ @x or a@^b_{cd} phantom box (occupies no width)
& &{space} inserts space of specified length
~ ~a{.8-} overprints '-' on 'a', raised by .8
times the current fontsize

The markup control characters act on the following single character or bracketed clause. The bracketed clause may contain a string of characters with no additional markup, e.g. 2^{10}, or it may contain additional markup that changes font properties. Font specifiers MUST be preceded by a '/' character that immediately follows the opening '{'. If a font name contains spaces it must be enclosed in single or double quotes.

Examples: The first example illustrates nesting one bracketed clause inside another to produce a boldface A with an italic subscript i, all in the current font. If the clause introduced by :Normal were omitted the subscript would be both italic and boldface. The second example illustrates the same markup applied to font "Times New Roman" at 20 point size.

     {/:Bold A_{/:Normal{/:Italic i}}}
     {/"Times New Roman":Bold=20 A_{/:Normal{/:Italic i}}}

The phantom box is useful for a@^b_c to align superscripts and subscripts but does not work well for overwriting a diacritical mark on a letter. For that purpose it is much better to use an encoding (e.g. utf8) that contains letters with accents or other diacritical marks. See set encoding. Since the box is non-spacing, it is sensible to put the shorter of the subscript or superscript in the box (that is, after the @).

Space equal in length to a string can be inserted using the '&' character. Thus

        'abc&{def}ghi'

would produce

        'abc   ghi'.

The '~' character causes the next character or bracketed text to be overprinted by the following character or bracketed text. The second text will be horizontally centered on the first. Thus '~a/' will result in an 'a' with a slash through it. You can also shift the second text vertically by preceding the second text with a number, which will define the fraction of the current fontsize by which the text will be raised or lowered. In this case the number and text must be enclosed in brackets because more than one character is necessary. If the overprinted text begins with a number, put a space between the vertical offset and the text ('~{abc}{.5 000}'); otherwise no space is needed ('~{abc}{.5---}'). You can change the font for one or both strings ('~a{.5 /*.2 o}'---an 'a' with a one-fifth-size 'o' on top---and the space between the number and the slash is necessary), but you can't change it after the beginning of the string. Neither can you use any other special syntax within either string. Control characters must be escaped, e.g. '~a{.8\^}' to print รข. See escape sequences below.

Note that strings in double-quotes are parsed differently than those enclosed in single-quotes. The major difference is that backslashes may need to be doubled when in double-quoted strings.

The file "ps_guide.ps" in the /docs/psdoc subdirectory of the gnuplot source distribution contains more examples of the enhanced syntax, as does the demo enhanced_utf8.dem

Subtopics