Next: pslatex_and_pstex, Previous: png_(OLD), Up: terminal
Several options may be set in the postscript driver.
Syntax:
set terminal postscript {<mode>} {enhanced | noenhanced} {color | colour | monochrome} {blacktext | colortext | colourtext} {solid | dashed} {dashlength | dl <DL>} {linewidth | lw <LW>} {<duplexing>} {rounded | butt} {fontfile [add | delete] "<filename>"} {palfuncparam <samples>{,<maxdeviation>}} {"<fontname>"} {<fontsize>}
where <mode> is `landscape`, `portrait`, `eps` or `default`; `enhanced` enables enhanced text mode features (subscripts, superscripts and mixed fonts). See `enhanced` for more information. Option `color` enables color; `blacktext` forces all text to be written in black even in color mode; `solid` draws all plots with solid lines, overriding any dashed patterns; `dashlength` or `dl` scales the length of the dashed-line segments by <DL> (which is a floating-point number greater than zero); `linewidth` or `lw` scales all linewidths by <LW>; <duplexing> is `defaultplex`, `simplex` or `duplex` ("duplexing" in PostScript is the ability of the printer to print on both sides of the same page—don't set this if your printer can't do it); `rounded` sets line caps and line joins to be rounded; `butt` is the default, butt caps and mitered joins; `"<fontname>"` is the name of a valid PostScript font; and `<fontsize>` is the size of the font in PostScript points. In addition to the standard postscript fonts, an oblique version of the Symbol font, useful for mathematics, is defined. It is called" "Symbol-Oblique".
`default` mode sets all options to their defaults: `landscape`, `monochrome`, `dashed`, `dl 1.0`, `lw 1.0`, `defaultplex`, `noenhanced`, "Helvetica" and 14pt. Default size of a PostScript plot is 10 inches wide and 7 inches high.
`palfuncparam` is only available if compiled with pm3d support. It controls how `set palette functions` are encoded as gradients in the output. Analytic color component functions (set via `set palette functions`) are encoded as linear interpolated gradients in the postscript output: The color component functions are sampled at <samples> points and all points are removed from this gradient which can be removed without changing the resulting colors by more than <maxdeviation>. For almost every useful palette you may savely leave the defaults of <samples>=2000 and <maxdeviation>=0.003 untouched.
`eps` mode generates EPS (Encapsulated PostScript) output, which is just regular PostScript with some additional lines that allow the file to be imported into a variety of other applications. (The added lines are PostScript comment lines, so the file may still be printed by itself.) To get EPS output, use the `eps` mode and make only one plot per file. In `eps` mode the whole plot, including the fonts, is reduced to half of the default size.
Fonts listed by `fontfile` or `fontfile add` encapsulate the font definitions of the listed font from a postscript Type 1 or TrueType font file directly into the gnuplot output postscript file. Thus, the enclosed font can be used in labels, titles, etc. See the section `postscript fontfile` for more details. With `fontfile delete` a fontfile is deleted from the list of embedded files.
Examples:
set terminal postscript default # old postscript set terminal postscript enhanced # old enhpost set terminal postscript landscape 22 # old psbig set terminal postscript eps 14 # old epsf1 set terminal postscript eps 22 # old epsf2 set size 0.7,1.4; set term post portrait color "Times-Roman" 14 set term post "VAGRoundedBT_Regular" 14 fontfile "bvrr8a.pfa"
Linewidths and pointsizes may be changed with `set style line`.
The postscript driver supports about 70 distinct pointtypes, selectable through the `pointtype` option on `plot` and `set style line`.
Several possibly useful files about `gnuplot`'s PostScript are included in the /docs/psdoc subdirectory of the `gnuplot` distribution and at the distribution sites. These are "ps_symbols.gpi" (a `gnuplot` command file that, when executed, creates the file "ps_symbols.ps" which shows all the symbols available through the postscript terminal), "ps_guide.ps" (a PostScript file that contains a summary of the enhanced syntax and a page showing what the octal codes produce with text and symbol fonts), "ps_file.doc" (a text file that contains a discussion of the organization of a PostScript file written by `gnuplot`), and "ps_fontfile_doc.tex" (a LaTeX file which contains a short documentation concerning the encapsulation of LaTeX fonts with a glyph table of the math fonts).
A PostScript file is editable, so once `gnuplot` has created one, you are free to modify it to your heart's desire. See the postscript section for some hints.
— ENHANCED POSTSCRIPT —
Several terminal types support an enhanced text mode in which additional formatting information is embedded in the text string.
Control Examples Explanation ^ a^x superscript _ a_x subscript @ @x or a@^b_c phantom box (occupies no width) & &{space} inserts space of specified length ~ ~a{.8-} overprints '-' on 'a', raised by .8 times the current fontsize
Braces can be used to place multiple-character text where a single character is expected (e.g., 2^{10}). To change the font and/or size, use the full form: {/[fontname][=fontsize | *fontscale] text}. Thus {/Symbol=20 G} is a 20-point GAMMA and {/*0.75 K} is a K at three-quarters of whatever fontsize is currently in effect. (The '/' character MUST be the first character after the '{'.)
If the encoding vector has been changed by encoding, the default encoding vector can be used instead by following the slash with a dash. This is unnecessary if you use the Symbol font, however—since /Symbol uses its own encoding vector, `gnuplot` will not apply any other encoding vector to it.
The phantom box is useful for a@^b_c to align superscripts and subscripts but does not work well for overwriting an accent on a letter. (To do the latter, it is much better to use 'set encoding iso_8859_1' to change to the ISO Latin-1 encoding vector, which contains a large variety of letters with accents or other diacritical marks.) 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. You can, of course, use control characters by escaping them (see below), such as '~a{\\^}'
You can access special symbols numerically by specifying \\character-code (in octal), e.g., {/Symbol \\245} is the symbol for infinity.
You can escape control characters using \\, e.g., \\\\, \\{, and so on.
But be aware 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.
Examples (these are hard to describe in words—try them!):
set xlabel 'Time (10^6 {/Symbol m}s)' set title '{/Symbol=18 \\362@_{/=9.6 0}^{/=12 x}} \\ {/Helvetica e^{-{/Symbol m}^2/2} d}{/Symbol m}'
The file "ps_guide.ps" in the /docs/psdoc subdirectory of the `gnuplot` source distribution contains more examples of the enhanced syntax.
— EDITING POSTSCRIPT —
The PostScript language is a very complex language—far too complex to describe in any detail in this document. Nevertheless there are some things in a PostScript file written by `gnuplot` that can be changed without risk of introducing fatal errors into the file.
For example, the PostScript statement "/Color true def" (written into the file in response to the command `set terminal postscript color`), may be altered in an obvious way to generate a black-and-white version of a plot. Similarly line colors, text colors, line weights and symbol sizes can also be altered in straight-forward ways. Text (titles and labels) can be edited to correct misspellings or to change fonts. Anything can be repositioned, and of course anything can be added or deleted, but modifications such as these may require deeper knowledge of the PostScript language.
The organization of a PostScript file written by `gnuplot` is discussed in the text file "ps_file.doc" in the docs/ps subdirectory of the gnuplot source distribution.
— POSTSCRIPT FONTFILE —
The `fontfile` or `fontfile add` option takes one file name as argument and encapsulates this file into the postscript output in order to make this font available for text elements (labels, tic marks, titles, etc.). The `fontfile delete` option also takes one file name as argument. It deletes this file name from the list of encapsulated files.
The postscript terminal understands some font file formats: Type 1 fonts in ASCII file format (extension ".pfa"), Type 1 fonts in binary file format (extension ".pfb"), and TrueType fonts (extension ".ttf"). Pfa files are understood directly, pfb and ttf files are converted on the fly if appropriate conversion tools are installed (see below). You have to specify the full filename with the extension. Each `fontfile` option takes exact one font file name. This option can be used multiple times in order to include more than one font file.
The font file is searched in the working directory and in all directories listed in the fontpath which is determined by fontpath. In addition, the fontpath can be set using the environment variable GNUPLOT_FONTPATH. If this is not set a system dependent default search list is used. See fontpath for more details.
For using the encapsulated font file you have to specify the font name (which normally is not the same as the file name). When embedding a font file by using the `fontfile` option in interactive mode, the font name is printed on the screen. E.g.
Font file 'p052004l.pfb' contains the font 'URWPalladioL-Bold'. Location: /usr/lib/X11/fonts/URW/p052004l.pfb
When using pfa or pfb fonts, you can also find it out by looking into the font file. There is a line similar to "/FontName /URWPalladioL-Bold def". The middle string without the slash is the fontname, here "URWPalladioL-Bold". For TrueType fonts, this is not so easy since the font name is stored in a binary format. In addition, they often have spaces in the font names which is not supported by Type 1 fonts (in which a TrueType is converted on the fly). The font names are changed in order to eliminate the spaces in the fontnames. The easiest way to find out which font name is generated for use with gnuplot, start gnuplot in interactive mode and type in "set terminal postscript fontfile '<filename.ttf>'".
For converting font files to pfa format the conversion tool has to read the font from a file and write it to standard output. For pfb files "pfbtops" is a tool which can do this. If this program is installed on your system the on the fly conversion should work. Just try to encapsulate a pfb file. If the compiled in program call does not work correctly you can specify how this program is called by defining the environment variable GNUPLOT_PFBTOPFA e.g. to "pfbtops %s". The `%s` will be repeated by the font file name and thus has to exist in the string. If you don't want to do the conversion on the fly but get a pfa file of the font you can use the tool "pfb2pfa" which is written in simple c and should compile with any c compiler. It is available from many ftp servers, e.g. ftp://ftp.dante.de/tex-archive/fonts/utilities/ps2mf/ In fact, "pfbtopfa" and "pfb2ps" do the same job. "pfbtopfa" puts the resulting pfa code into a file, whereas "pfbtops" writes it to standard output.
TrueType fonts are converted into Type 1 pfa format, e.g. by using the tool "ttf2pt1" which is available from http://ttf2pt1.sourceforge.net/ If the builtin conversion does not work, the conversion command can be changed by the environment variable GNUPLOT_TTFTOPFA. For usage with ttf2pt1 it may be set to "ttf2pt1 -a -e -W 0 %s - ". Here again, `%s` stands for the file name.
For special purposes you also can use a pipe (if available for your operating system). Therefore you start the file name definition with the character "<" and append a program call. This program has to write pfa data to standard output. Thus, a pfa file may be accessed by `set fontfile "< cat garamond.pfa"`.
For example, including Type 1 font files can be used for including the postscript output in LaTeX documents. The "european computer modern" font (which is a variant of the "computer modern" font) is available in pfb format from any CTAN server, e.g. ftp://ftp.dante.de/tex-archive/fonts/ps-type1/cm-super/ For example, the file "sfrm1000.pfb" contains the normal upright fonts with serifs in the design size 10pt (font name "SFRM1000"). The computer modern fonts, which are still necessary for mathematics, are available from ftp://ftp.dante.de/tex-archive/fonts/cm/ps-type1/bluesky With these you can use any character available in TeX. However, the computer modern fonts have a strange encoding. (This is why you should not use cmr10.pfb for text, but sfrm1000.pfb instead.) The usage of TeX fonts is shown in one of the demos. The file "ps_fontfile_doc.tex" in the /docs/psdoc subdirectory of the `gnuplot` source distribution contains a table with glyphs of the TeX mathfonts.
If the font "CMEX10" is embedded (file "cmex10.pfb") gnuplot defines the additional font "CMEX10-Baseline". It is shifted vertically in order to fit better to the other glyphs (CMEX10 has its baseline at the top of the symbols)."