Notes on Graph Plotting and Co-ordinates.

General principles for constructing a graph.

When a graph is created we first construct a set of axes and 
then plot the data on the graph at positions determined by 
these axes. Conventionally, for simple two dimensional plots the 
two aes (x and y) are at right angle and intersect at the origin 
of the graph,but neither of these conditions is 
essential.

The two axes may be displaced relative to the plotting area, 

They may also be non-orthogonal, as shown below.

In practice non-orthogonal axes arise mainly when creating 
three dimensional plots. We also have other co-ordinate systems, 
such as polar co-ordinates or the sets of intersecting arcs that 
are used in Smith's Charts. There is also the question of the 
axis scales, which may be linear, logarithmic or perhaps based 
on the probability distribution, or in special cases on hyperbolic 
functions or derived from other specialised functions.

In plotting data on a graph we first have to place the data in 
its correct position relative to the axes and then translate 
this to the corresponding point on the screen or printer paper. 

In this note we will concentrate on straight-line axes and defer 
consideration of polar co-ordinates or Smith's charts till later. 
Our primary requirement is to produce an algorithm for trasforming 
a pair of data co-ordinates (xd,yd) to a set of paper co-ordinates 
(xp,yp) when the data is plotted against a pair of axes.
The axes may be offset, individually at any angle relative to the 
paper and may be either linear or logarithmic (or use some other 
scaling function. Each axis is then described by five parameters

   (1) Lower scale limit              (ScaleLo)
   (2) Upper scale limit              (ScaleHi)
   (3) Its physical Length            (AxisLength)
   (4) Its angle relative to that of  (AxisAngle)
       a conventional x-axis.
   (5) Its scale type                 (lin, log, etc.)

(The conventional x axis is horizontal with scale values 
 increasing from left to right.)

To cover displaced axes it is then necessary to define a 
physical origin (xo,yo) which is the point on the paper
corresponding to the point (xScaleMin,yScaleMin) defined
by the lower limits of the axes.) 

The process of plotting a point is then as follows.

   (a) xd and yd are first converted to linear displacements 
       xl and yl in the directions of the x and y axis.
   (b) These are then converted to horizontal and vertical
       displacements (xc,yc)
   (c) These are finally added to the origin co-ordinates 
       to obtain the actual paper point xp,yp.

Step(a)
  For a linear x axis: 
          xl = (xd-ScaleLo)*Axislength/(ScaleHi-ScaleLo)
             = a.xd + b
          yl = (yd-ScaleLo)*Axislength/(ScaleHi-ScaleLo)
             = c.yd + d

   where   a = length/ScaleHi-Scalelo)
           b = -a*ScaleLo
           and similarly for c and d
  
 For a logarithmic axis:
          xl = (log(xd)-Log(ScaleLo))*AxisLength
                /(Log(ScaleHi)-Log(ScaleLo))

          and similary for y.

   Note that for log axis all of x,y,ScaleHi,Scalelo must be
   greater than zero

Step (b)
  This step must involve both xl and yl in deriving each of 
  xc and yc. Suppose the x-axis angle is Theta and the y-axis 
  angle is Phi. Then:

          xc = xl.cos(Theta) + yl.cos(Phi)
          yc = xl.sin(theta) + yl.sin(Phi) 

Step (c)

          xp = xo + xc
          yp = yo + yc       

This completes the transformation.

In GLE2000 the paper co-ordinates will now be the local 
coordinate set in cms, and are subjected to further 
transformations according to any scaling or rotation 
in force and are then finally are converted to screen pixel  or
printer pixel coordinates,

