PLOTTING
(Back to topic index)
There are at least two styles of plotting.

            1) Vector plots: Plot data logically by moving a pen as a draftsman would do.
 
            2) Raster plots: Plot data by turning the bits of the image (pixels) on and off
 
 

CALCOMP subroutines:
        1)CALL PLOT (X, Y, IPEN)
                                X, Y – the location of the pen in inches from the origin.
                                IPEN –an integer code to tell the pen whether it should be up or down during
                                the move to (X, Y).
                                If IPEN is equal to:+ 2 the pen is down during the move.
                                                             + 3 the pen is up during the move.
                                                             – 2 or –3 same as above, except the origin is reset at (X,Y).
 

        2) NUMBER (xpos, ypos, height, fpn, angle, ndec)

 

        3) AXIS (xpos, ypos, title, nchar, axlen, angle, firstv, deltav)
 
 

        4) SYMBOL (xpos, ypos, height, symbol, angle, nchar)

                    (2 types) One type of call to SYMBOL creates a centered non-alphanumeric symbol. The other type creates an uncentered alphanumeric symbol useful for plotting titles and numbers.When you make a plot, you have to know the size of your drawing area and the size of your data to find the scale factor required. This scale factor is important so you can fit all of your data onto a plot window. Any vector that is drawn outside of the plot window will be truncated.

 
 
c PROGRAM SAMPLE

c this is a sample of how to plot using the idea of a pen plotter.

c x contains the vector array to be plotted.

c the paper is assumed to be 8" by 10". a single period

c sine wave is read in as x from a file, sin.dat. a subroutine

c myplot is called that handles a vector. the axis are drawn.

c variables:

c x - values to be plotted

c xsize - size of paper in x-direction

c ysize - size of paper in y-direction

c lgunit - logical unit number for plot file, produces zetann.plt

c irel,idum - required dummy variables

parameter (mx = 500)

real x(mx),xsize,ysize

integer n,m,irel,lgunit

parameter(lgunit=20,irel=0,idum=0)

c paper is 10.0" by 8.0"

xsize=10.0

ysize=8.0

c read in data from file mx

open(unit=12,file='sin.dat',status='old')

do j=1,mx

read(12,*,end=101) x(j)

end do

101 n=j-1

rewind (12)

close (12)

c---------- open plotting routines --------
 

call plots(irel,idum,lgunit)
 

c move origin to 1.0", 1.0", with pen up (-3) and reset origin
 

call plot(1.,1.,-3)

c call actual plotting subroutine to plot n values of x

call myplot(x,n,xsize,ysize)

c------------ close plotting routines and save the results -------

call plot(0.,0.,999)

stop
end
 
 

subroutine myplot(y,n,xsize,ysize)

c this subroutine plots y, a vector of values

c variables:

c y - values to be plotted

c n - number of values of y

c xsize - size of paper in x direction

c ysize - size of paper in y-direction

c ymax - maximum value of y

c ymin - minimum value of y

c yscal - scaling for y-axis

c xscal - scaling for x-axis

real y(*),xsize,ysize

integer n

c find the max and min values of y

ymax=-1.e32

ymin=1.e32

do j=1,n

ymax=amax1(ymax,y(j))

ymin=amin1(ymin,y(j))

end do

c determine y data scale factor, yscal = inches / data

yscal=ysize/(ymax-ymin)

c determine x scale factor, xscal = inches / data

c note we have n points to plot

c xsize is length of x-axis in inches.

xscal=xsize/n

c plot axes

c first the y-axis

call axis(0.,0.,5hvalue,-5,ysize,90.,ymin,1./yscal)

c now the x-axis
 

call axis(0.,0.,4htime,4,xsize,0.,0.,1./xscal)
 

c plot relative to assumed origin at 0.,0.

c note for min data value to be at 0.,0. we need to plot

c relative to ymin.

c first plot the first point. (initializes pen position.)

xx=0.

yy=(y(1)-ymin)*yscal

call plot(xx,yy,3)

c plots the rest of the data

do 20 j=1,n-1

xx=j*xscal

yy=(y(j+1)-ymin)*yscal

call plot(xx,yy,2)

20 continue

c move pen back to the origin with pen up

call plot(0.,0.,3)

return

end
 

call axis(xpos,ypos,mess,nchar,axlen,angle,firstv,deltav)

where mess is 6hmydata then nchar = 6, axlen is in inches

nchar = 0 no messege

> 0 on counter clockwise side of axis

< 0 on clockwise side of axis

firstv - value of first tick

deltav - increment between ticks (of values)

call axis(0.,0.,4hdata,-4,ysize,90.,ymin,1./yscal) (y axis)

call axis(0.,0.,7hsamples,7,xsize,0.,0.,1./xscal) (x axis)
 

call number(xpos,ypos,height,fpn,angle,ndec)
 

ndec = 0 integer part of fpn and a "."

= -1 integer part of fpn and no "."

< -1 number of decimals truncated

> 1 number of decimals rounded to

so: -123.45678 ndec=2, -123.46

call symbol(xpos,ypos,height,10hmyplotisok,angle,nchar)

height is in inches, angle in degrees

nchar is 10 for example

xpos=999., ypos=999. , where last character ended

(start)