Axe2.ps

This function is used to define a plot window and set a number of global variables. There are 3 variants identified by the number of arguments passed on the stack. The most simple is variant 2: one argument defining the user coordinate system, using default values for the window size and position.The following variables are used (as default) or set by Axe2 depending on the variant used.
% Position and size of the plot window in paper coordinate
% which can be modified before calling Axe2 with 0 or 1 argument.
/Width 150 mm def
/Height Width 2 div 3 sqrt mul def
/Left 50 mm def
/Bottom 30 mm def

% Axe2 called without arguments will set
% the following dependant variables with the following code
/Right Left Width add def
/Top Bottom Height add def

% Edges of the plot window in user coordinates. These variables can be set
% before calling Axe2 with 0 arguments.
/Xmin 0 def
/Xmax 1 def
/Ymin 0 def
/Ymax 0 def
return
1 Axe2 No arguments given in the stack; The values of the global variables will be used to define the coordinates position and size of the plot window.
2 array1 Axe2 One argument on the stack: array1 must be an array of 4 real numbers defining the boudary values of the window in user coordinates in the order [ Xmin Xmax Ymin Ymax ]. The default size and position of the plot window are used (defined by /Bottom /Left /Width and /Height).
3 array2 array1 Axe2 Two arguments on the stack: array1 same as above;  array2 is a vector of 4 numbers assigned to /Left /Right /Bottom and /Top in that order in paper coordinates, i.e. matching the corresponding user's coordinates values in a1. In this case consistent values of /Width and /Height are calculated.




Win

Save or Set a plot window in a variable.
return
1 name Win Save the current plot window (set by Axe2 or Axe3) in the variable name
[50 550 50 550][ 0 100 0 100 ] Axe2
/W1 Win
[50 550 600 800][ 0 1 5 10 ] Axe2
/W2 Win
2 notname Win Set the plot window from the argument set in a previous call to Win of type 1.
W1 Win
[ 0.1 0.25 ] Plot
W2 Win
[ 0.3 6.7 ] Plot

GradX GradY

 Place graduations on a rectangular plot window defined by Axe2, with/without labels and a title using the current font. The optional parameters given in any order are identified by their type. It is possible to use several calls to Grad* functions to use different font sizes or place several sets of graduations with different colors. It is the user's responsibility to use sensible graduation values, no sanity check is made.

TODO: control length of tic marks and place graduation at non standard location ( this may be needed to overlay plots sharing X scale but using different Y scales, which should appear in different places as required... may be introduce an optional plugin to do that if needed )
  • title: string
    Title of the X or Y axis
  •  grads: array of strings
    Each string is used as a label at the position of its numerical value along with tick marks
  • labels: boolean
    If a false boolean value appears in the argument then the labels are omitted and only the graduations are drawn; this feature is needed when assembling multiple plots sharing either X or Y scales.
return
title grads labels GradX

( T \(K\) ) [ (500) (600) (700) ] GradX
[ (633.5) ] GradX
[ (10) (15) (20) ] ( G \(kJ\) )GradY


Plot modes

A set of functions enables to modify the plot mode: colors, symbol type, line width and type, line plot, symbols with / without lines, polygones or surfaces.
Circles Squares Diamonds Triangles Gradients Cross
Filled Empty Pen Dash Size Color

Plot command

The generic plot command is Plot its behavior is controlled by the plot mode functions. It takes the points coordinates from one or several arguments on the stack as explained below. The symbol shape plot mode commands are overloaded to behave as a plot command if they find points coordinates on the stack. The other plot commands are Lines Polygone and Surface. They all expect coordinates in the same way: see next paragraph.

Plot coordinates

  1. A vector with x y pairs;
  2. Two vectors of the same size: the first one with x values and the second y values;
  3. For evenly spaced data : the abscissa of the first point, the increment of x from one point to the next and a vector of y values.
% First method to give plot coordinates
[
1.5 10
2 20
3.5 30
4 40
] Plot

% second method
[ 1.5 2 3.5 4 ] [ 10 20 30 40 ] Plot

% third method
1.5 0.5 [ 10 20 30 40 ] Plot


Simple table tools


Data are often presented as tables with one column for X values and other columns for Y values. Some tools are provided to handle this kind of data. 

% some table of data ( we must know the number of columns
% because we have a flat vector in Postscript
%
/table [
1.5 0 10
2 1 20
3.5 2 30
4 3 40
] def
%
% to plot 2d column against the first
%
table 3 1 Col table 3 2 Col Plot
The Col function requires 3 arguments: the vector with the data, the number of columns and the index of the selected column.