PostScript Files


Contents Summary

Detailed Contents
Introduction
Command Line
File Format
Plot Instructions
Expressions
Curve Fitting
Three-Dimensional Plots
PostScript Files
Appendix: Line Styles
Index


8 PostScript Files

Hard copy may be obtained from DigiPlot in one of two ways: DigImage may be used to produce a screen dump of a buffer on which DigiPlot has operated, or DigiPlot may write directly to a PostScript output file using the /P PS_File command line switch. The latter method will normally be preferable in the majority of cases.

8.1 TYPES OF POSTSCRIPT

There are two common forms of PostScript files: printable PostScript and encapsulated PostScript. By convention these are normally given the extensions .PS and .EPS respectively. As the name suggests, a printable PostScript (.PS) file will be printed if you send it to a suitable PostScript printer. It contains everything required to produce the final page or pages of text and/or graphics. In contrast, if you send an encapsulated PostScript (.EPS) file to the same printer, you should not get anything out of it. Encapsulated PostScript is intended as a method of importing the text or graphics it describes into another document or application. The .EPS file is responsible for drawing its contents in the printer's memory, but the document containing it is responsible for printing it where it wants and at the size it requires.

Ultimately the encapsulated (.EPS) form is more flexible and more useful. As a result we would recommend that you use it in preference to the .PS form. To enable you to print a DigImage .EPS file directly without importing it into some other application, the DigiFile utility offers the ability to convert the file to a .PS and send it directly to the printer. Note that DigImage can also convert .PS files (provided they were created by DigImage version 1.4 or later) into .EPS files.

DigImage also handles a third, nonstandard form of PostScript: Data only PostScript, .DPS. A .DPS file contains only the data required for the plotting and not the normal prologue of procedures. The main purpose of this form is to provide a more compact representation of the plot. With some document systems it is possible to include the prologue once and only once, no matter how many plots are used in the document. Unfortunately with others the prologue must be included with every plot. In the former case the .DPS form may be used to save a considerable amount of space and speed up printing, while in the latter case the .EPS form must be used. DigiFile is able to convert it to either the .PS or .EPS forms. It is not, however, possible to convert .PS or .EPS into .DPS.

Which type of PostScript is produced by the output of DigiPlot and DigiFile will normally be determined by the extension given to the output file. Printable PostScript is produced if .PS is specified, encapsulated PostScript is generated with the .EPS extension and data only PostScript with the .DPS extension. If no extension is specified, the type of PostScript is determined by the setting in [;P Printers] in CONFIGUR.EXE. The appropriate extension will be added automatically. Any other extension will also produce PostScript of the default type (but using the specified extension).

8.2 CUSTOMISING

While simply adding the /P PS_File switch to the command line will produce reasonable plots in the majority of cases, there may be times when you may wish to change some of the default settings. This section considers the W and WF plot instructions which may be used within a plot file to directly manipulate the PostScript output file and so alter the default settings. Before discussing how to change the defaults, and the effects any changes will have, we shall start by outlining the basic structure of the PostScript output file.

PostScript is used in a wide variety of laser printers to control the printing of pages of text and graphics. Unlike other common printer control languages such as Hewlett Packard's PCL5, PostScript is in fact a fully fledged computer language containing most of the abilities of other high level languages such as Basic or Fortran. PostScript, however, is an interpreted, stack oriented language using reverse polish notation in a manner very similar to Forth. The use of reverse polish enables a high degree of flexibility and much faster execution than traditional interpreted languages. The disadvantages are that PostScript is somewhat less easy to read or write than a traditional computer language.

DigImage and DigiPlot employ the high level language abilities of PostScript to greatly simplify the method of printing and plotting. In most applications, the computer controls the printer through the PostScript. For example, the computer dictates where on the printed page a line should start, and where it should end. In contrast DigImage and DigiPlot simply provide the printer with a PostScript program so that it may determine from the raw data where the line is to go. The PostScript program effectively adds further high level commands to PostScript to produce process the data. The advantages of this strategy are much greater flexibility and the possibility to use the same plotting routines from any language on any computer.

A DigImage or DigiPlot PostScript file is normally divided into three sections. The first section contains a general prologue providing details for common commands and processes and handling any errors which occur. This section is the same in all DigImage and DigiPlot PostScript output files and is added to the file by copying it from %DIGIMAGE%\POSTSCR\HEADER.PS. The second section contains the PostScript procedures required to process the raw data and render it on the page. There are a number of different sets of these procedures depending on exactly what is being plotted. The set required by DigiPlot is copied to the output file from %DIGIMAGE%\POSTSCR\GRAPHVDU.PS. The final section of the PostScript output file contains the data to be plotted along with simple high level calls to procedures in the first and second sections to actually render the data.

Defaults for the basic parameters controlling the appearance of a plot are contained at the start of the second section. It is these defaults which the user may wish to override. Overriding a setting is simply a matter of redefining it using the W or WF plot instructions. The W instruction will simply insert the text following directly into the PostScript file at the point where it is issued. For example,

# Example of suppressing axis grid
C -1 1 0 10
W /AxisGrid false def
A
...


will prevent the normal axis grid being drawn on the hard copy. Instead simple tick marks along the axes will be used. The /AxisGrid false def which is inserted into the PostScript output file redefines the PostScript variable AxisGrid which previously had the value true. The / character indicates that the variable is to be defined (instead of used), and the def tells the printer the definition of the new value is complete. Note that PostScript is case sensitive, hence /axisgrid false def would not have the desired effect. Note also that at the end of each plot (e.g. when a CL instruction is issued) any changes made using W (or WF) are restored to their original settings.

If you wish to define a number of the default settings, or you wish to utilise the same settings from a number of plot files, it is more convenient to group the definitions in a special defaults file and include the entire file using the WF file plot instruction. Below is a listing of the default settings part of %DIGIMAGE%\POSTSCR\GRAPHVDU.PS.

/AxesWidth 0.5 mm def               % Width of frame around plot
/AxisGrid true def                  % Enables/suppresses the drawing
                                    % of an axis
/AxesScalePS 12 def                 % Basic point size of axes scales
/AxesScaleFont /Times-Roman def     % Font for axes scales
/AxesLabelPS 14 def                 % Basic point size of axes titles
/AxesLabelFont /Times-Roman def     % Font for axes titles
/GraphTitlePS 16 def                % Basic point size for graph title
/GraphTitleFont /Times-Roman def    % Font for graph title
/LineWidth 0.2 mm def               % Base width of plotted lines
/LinePatternScale 1 def             % Changes the basic length of
                                    % the line patterns
/MarkSize 1.5 mm def                % Base size of plotted marks
/MarkWidth 0.2 mm def               % Width of lines used for marks
/FillMarks false def                % Enable/disable filling of marks
/MarkColour 0 def                   % Grey level for filling marks
                                    % (if enabled)
/nSigDigits 4 def                   % The number of significant digits
                                    % used for real numbers
/PageWidth 210 mm def               % Width of A4 page
/PageHeight 295 mm def              % Height of A4 page
/nPlotsPerPage 1 def                % Number of plots on each page

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Data controlling layout of plots on a page. The layout is selected
% by iPlotLayoutPtr.
%
%   nPlots      The number of plots per PostScript page
%   Width       The width of each plot
%   Text        The scale factor for text
%   Line        The scale factor for line widths
%   Mark        The scale factor for mark sizes
%   Axes        The scale factor for axes
%   Rot         The rotation of each plot
%   PageOrigin  Specifies the location of the bottom left corner of
%               the page
%   PlotOrigin  Specifies the location of the origin for each
%               individual plot
%
% Standard plots have iPlotLayoutPtr < 10.
% Values of iPlotLayoutPtr between 10 and 19 (inclusive) reserve extra
% space for the alternate x and y axes available trhough
%
% DrawAlternateXAxis etc. The basic layout is the same as for the
% standard plots.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Any or all of these settings may be changed. The comments (started by the % character) indicate what use each setting is put to. Lists of values enclosed in square brackets ([..]) are arrays. Expressions enclosed in braces {..} are not executed until the variable/procedure is accessed while other expressions are evaluated at the point the file is included. The default units are points (1/72"). The procedure mm may be used to specify sizes in millimetres. Refer to PostScript language documentation for details of syntax. Refer to Document\PSLayOut.DOC for details on customising the layout of multiple plots on a single page.

DigiPlot PostScript files also includes a number of other features which are not supported or necessary when plotting on the computer monitor or frame grabber buffer. These features should be accessed through the W plot instruction when they are required. A summary of them is given in the table below. Remember the procedure names (and predefined constants such as true and false) are case sensitive.

Procedure Name ExampleAction
Clip W Clip Turns plot clipping on. By default anything plotted outside the region defined by the axes will still be rendered on the page with PostScript files. Executing the Clip procedure will suppress any plotting outside the region defined by the axes. This clipping is turned off by UnClip. Note that graph and axis titles can not be printed between a Clip and UnClip pair.
UnClip W UnClip Turns off the clipping started by the Clip procedure.
DrawAlternateXAxis W 1 100 false DrawAlternateXAxis Procedure to add a secondary x axis above the main body of the plot. This secondary axis does not affect the data plotted. The W plot instruction issuing this procedure should be given before any A plot instruction (to draw the main axes). The procedure expects either two or three parameters (before the procedure name). The first two are the minimum and maximum values for the alternate axis. The optional third indicates whether the axis is linear (true) or logarithmic (false). If the optional logical parameter is not given, then the axis will be the same type as the main x axis. Note that this procedure turns off the normal axis grid, replacing it with tick marks below and to the left of the plot.
DrawAlternateYAxis W 0 1.5 DrawAlternateYAxis This procedure is very similar to DrawAlternateXAxis except that it adds a secondary y axis to the right of the body of the plot. The parameters are the minimum and maximum y values and, optionally, a logical indicating a linear (true) or logarithmic (false) axis.
AlternateXTitle W (Dimensionless time) AlternateXTitle This procedure adds a title above the alternate x axis added by the DrawAlternateXAxis procedure. The W plot instruction issuing it may occur anywhere in the plot file, although it may be preferable to have it in close proximity to the DrawAlternateXAxis procedure. Note that the text for the title must be enclosed in brackets. If the text itself is ;to include brackets then those brackets must be prefixed by a backslash (\) character. See the next entry for an example. If the backslash character is to be included, it must also be prefixed by a backslash character (i.e. \\).
AlternateYTitle W (Length \(metres\)) AlternateYTitle This procedure is very similar to AlternateXTitle except that it places the title to the right of the alternate y axis. See previous entry for additional details.

8.3 CHANGING APPEARANCE

In addition to the methods described in the preceeding sections, the appearance of the PostScript output may be altered reterospectively by utilising the /U use_file option in DigiFile. This option inserts the specified use_file at the start of the PostScript describing each page. The contents of the use_file may be used to override the standard DigImage procedures defined in the Header.PS and GraphVDU.PS prologue files, or even redefine standard PostScript procedures. The same net effect may be achieved through W or WF plot instructions, but in a manner which is less convenient for most users.

Development of use_files requires a reasonable working knowledge of PostScript. From time-to-time specialised use_files will be released with DigImage. A list of these files and their effect may be found in the DigiFile documentation. One such example is the rendering of images with cross-hatching patterns rather than grey levels through /U Patterns.PS. This file is located in the DigImage\PostScript directory which will always be searched if the file is not found in the local directory.

Goto next document (LineStyles)


Links

DIGIPLOT

Contents
Index

OTHER

DigImage documentation page
DigImage home page
Stuart Dalziel's home page


Stuart Dalziel, last page update: 21 June 1999