Contact us Heritage collections Image license terms
HOME ACL Associates Technology Literature Applications Society Software revisited
Further reading □ Forword and contents1. Introduction2. Plotting a graph3. Device and coordinate selection4. The Graphics Library (New routines)5. Miscellaneous notesAppendices and references
ACD C&A INF CCD CISD Archives Contact us Heritage archives Image license terms

Search

   
ACLLiteratureICL 1906A manualsSMOG
ACLLiteratureICL 1906A manualsSMOG
ACL ACD C&A INF CCD CISD Archives
Further reading

Forword and contents
1. Introduction
2. Plotting a graph
3. Device and coordinate selection
4. The Graphics Library (New routines)
5. Miscellaneous notes
Appendices and references

2. PLOTTING A GRAPH

2.1 What is a Graph?

Graphs are pictorial representations of numeric data and include: histograms, pictograms, pie charts, ogives, scatter diagrams, bar charts, contour plots and, of course, plots of F(X) against X. When using a computer system to produce graphs one has the advantage that the initial data can be verified, analysed, interpreted and plotted all in one go. In some cases the initial data is produced on the computer as well. In SMOG and SPROGS there are various high level routines to aid the user in the production of graphs but these will be explained towards the end of this chapter. The first few sections of this chapter will explain how to develop one's own graph plotting routine using the basic routines of SMOG/SPROGS.

2.2 Plot F(X) Against X (The Hard Way)

Let X range from 0 to 200 and F(X) range from 1 to 10, and for the purpose of this example read in the 20 pairs of values in table 2.1.

X    0  10  15  25  35  50  55  70  90  100
F(X) 3   5   6   7   8   9   9   9   8    7
X  105 115 135 150 170 175 180 190 195 200
F(X) 5   3   2   2   4   6   7   7   8   9
Table 2.1

One can make various assumptions about X and F(X). Firstly, as data is always punched correctly the values will all be within the specified range, secondly, X and F(X) can be read in as REAL numbers.

The output of the graph can go to the FR80's hardcopy camera in many-up mode (see section 5.3). One has to initialise the graphics system and choose an output device before any other graphics routines are called, and in this example this is achieved by calling the routine FRHCM. The next routine needed is one to tell the system what film area is to be used. It is advisable to use CINE until one is more familiar with the system. The final initialising routine required is one to tell the system what coordinates are to be used. If one specifies (0,1) to (200,10) for the bottom left and top right corners of a rectangular area then this will be alright but will not leave a margin around the edge for, say, titling and labelling axes. Thus one can leave suitable margins by specifying a larger area than is actually required to plot on.

In this example (-20,-1) to (200,12) is a reasonable choice; to inform the system of this, one calls LIMITV with the above values. The initialising section of the program is as follows:

C--INITIALISE SYSTEM AND SELECT HARDCOPY
C--CAMERA IN -"MANY-UP" MODE.
      CALL FRHCM 
C--SELECT THE "CINE" AREA.
      CALL CINE
C--SET UP COORDINATE SYSTEM.
      CALL LIMITV(-20.0,-1.0,200.0,12.0)

FRHCM may be called once only but CINE and LIMITV can be called as often as is necessary.

The next thing to do is to read in the X and F(X) values and plot the graph. As the values of X are in ascending order we can draw a line from one point to the next by using the routine TOXY. All that remains is to say where the first point is, and this can be achieved using the routine SETXY. The section of the program to plot the graph is as follows

C---READ THE FIRST POINT.
      READ(1,5)X,FX 
    5 FORMAT(2F5.0)
      CALL SETXY(X,FX)
C---READ THE  REMAINING  19 POINTS AND 
C---DRAW THE LINES.
      DO 10 I=1,19
      READ(1,5)X,FX
      CALL TOXY(X,FX) 
   10 CONTINUE

The graph is now complete apart from such minor details as axes, scales and titles which always seem to require more work than the actual plotting. In the next section the axes and tick marks will be drawn. The tick marks are drawn using special routines for drawing a series of parallel lines called HGRATX and HGRATY and the axes are drawn using the routine VEC as follows:

C---DRAW THE AXES.
      CALL VEC(0.0,1.0,200.0,1.0)
      CALL VEC(0,0,1.0,0.0,10.0) 
C---PUT TICK MARKS ON THE X-AXIS AND F(X)-AXIS
      CALL HGRATX(0.0,0.5,200.0,1.0,20)
      CALL HGRATY(-5.0,10.,0.0,10.0,9)

Note: The last argument in the graticule routines is INTEGER and the rectangle defined by the four coordinates just touches the appropriate axis.

Now the most tricky part of the whole job is actually writing titles and labels at the appropriate point on the graph. Firstly, one has to specify an appropriate size for the characters one wants to use and for this it is easiest to use the CHSIZE routine. The argument required is in terms of the Y (vertical) direction and in our example the total height is 13 units, therefore a suitable character size is about 0.2 giving a character height of l/65th of the frame height. Allowing for spacing between lines and characters this size will give about 40 lines of 80 characters. To position the strings of text use the routine SETXY and to output the text use the routine HTEXT which will output a string of text from the current point. To output the numbers, use the routine JTYPEN. The next piece of code will produce the title and labelling of the axes using the above four routines.

C---CHOOSE A CHARACTER SIZE.
      CALL CHSIZE(0.2) 
C---OUTPUT A TITLE FOR THE GRAPH.
      CALL SETXY(70.0,11.0)
      CALL HTEXT(23,'GRAPH OF F(X) AGAINST X') 
C---LABEL X-AXIS.
      CALL SETXY(-2.0,0.1)
      CALL JTYPEN(0,1)
      CALL SETXY(46.0,0.1)
      CALL JTYPEN(50,2)
      CALL SETXY(94.0,0.1)
      CALL JTYPEN(100,3)
      CALL SETXY(144.0,0.1)
      CALL JTYPEN(150,3)
      CALL SETXY(194.0,0.1)
      CALL JTYPEN(200,3) 
C---LABEL F(X)-AXIS.
      CALL SETXY(-10.0,0.9)
      CALL JTYPEN(1,1)
      CALL SETXY(-10.0,4.9)
      CALL JTYPEN(5,1)
      CALL SETXY(-14.5,9.9)
      CALL JTYPEN(10,2)

Finally one must remember to terminate the graphics part of the program with a call to ENDSPR and then enclose all of the above in a FORTRAN master segment to produce the following:

      MASTER EXAMPLE2 
C---INITIALISE SYSTEM AND SELECT HARDCOPY
      ......
      code in above order
      ......
      CALL JTYPEN(10,2) 
C---TERMINATE THE PLOTTING. 
      CALL ENDSPR 
      STOP 
      END

Note: All of the calls to the graphics routines could have themselves been in a subroutine or for that matter, several subroutines. The main point to remember is that initialising occurs first and termination occurs at the end.

This example uses the SMOG/SPROGS default program description segment.

No mention has as yet been made of which system will be used to run the program.

Finally, how does one calculate the coordinates for the text? By using a little intuition and a lot of trial and error!

For this example SMOG was used and the program was input to file :GRAFEX.PROGRAM2 and the data to file :GRAFEX.PROG2DATA. To compile, consolidate and run the program the following command was typed when logged in.

TASK F,SMOG,*CR :GRAFEX.PROGRAM2,#CR :GRAFEX.PROG2DATA,JT30  

The output produced was 3 listings and 1 piece of hardcopy from the FR80. One listing is the monitoring file of GEORGE commands ([1]A.2.5 and B.1.6), the second is the output from the compiler and consolidator, and the third gives details of the actual FR80 output, for example, what camera was used, (in this case, the hardcopy camera in "many-up" mode).

A listing of the program together with the FR80 output produced is shown below.

2.2.1 Listing of source, file is GRAFEX.PROGRAM2

      MASTER EXAMPLE2
C---INITIALISE SYSTEM AND SELECT HARDCOPY 
C---CAMERA IN "MANY-UP" MODE.
      CALL FRHCM 
C---SELECT THE "CINE" AREA.
      CALL CINE 
C---SET UP COORDINATE SYSTEM.
      CALL LIMITV (-20.0,-1.0,200.0,12.0) 
C---READ THE FIRST POINT.
      READ (1,5) X,FX 
    5 FORMAT (2F5.0)
      CALL SETXY (X,FX)
C---READ THE REMAINING 19 POINTS AND 
C---DRAW THE LINES.
      DO 10 I=1,19
      READ (1,5) X,FX
      CALL TOXY (X,FX) 
   10 CONTINUE 
C---DRAW THE AXES.
      CALL VEC (0.0,1.0,200.0,1.0)
      CALL VEC (0.0,1.0,0.0,10.0) 
C---PUT TICK MARKS ON THE X-AXIS AND F(X)-AXIS.
      CALL HGRATX (0.0,0.5,200.0,1.0,20)
      CALL HGRATY (-5.0,1.0,0.0,10.0,9) 
C---CHOSE A CHARACTER SIZE.
      CALL CHSIZE (0.2) 
C---OUTPUT A TITLE FOR THE GRAPH.
      CALL SETXY (70.0,11.0)
      CALL HTEXT (23,'GRAPH OF F(X) AGAINST X') 
C---LABEL X-AXIS.
      CALL SETXY (-2.0,0.1)
      CALL JTYPEN (0,1)
      CALL SETXY (46.0,0.1)
      CALL JTYPEN (50,2)  .
      CALL SETXY (94.0,0.1)
      CALL JTYPEN (100,3)
      CALL SETXY (144.0,0.1)
      CALL JTYPEN (150,3)
      CALL SETXY (194.0,0.1) 
      CALL JTYPEN(200,3)
C---LABEL F(X)-AXIS.
      CALL SETXY (-10.0,0.9) 
      CALL JTYPEN (1,1) 
      CALL SETXY (-10.0,4.9) 
      CALL JTYPEN (5,1) 
      CALL SETXY (-14.5,9.9)
      CALL JTYPEN (10,2)
C---TERMINATE THE PLOTTING.
      CALL ENDSPR
      STOP
      END 
****

2.2.2 Command obeyed to run job

The following command was issued when logged in:

TASK F,SMOG,*CR :GRAFEX.PROGRAM2,#CR :GRAFEX.PROG2DATA,JT30

2.2.3 FR80 output produced

Graph of F(X) against X

Graph of F(X) against X
Full image ⇗
© UKRI Science and Technology Facilities Council

2.3 Plot F(X) Against X (Not So Difficult)

In this example life is made a little easier by using some of the system routines to do some of the work. The major saving is made by replacing the ten calls to label the X-axis and the six calls for the F(X)-axis by a single call to the routine SCALA.

To allow comparison between the two methods the same data was used; it was in the file called PROG2DATA. The source file PROGRAM2 was edited to produce the file PROGRAM3. The changes are outlined below.

Firstly, if one refers to the third piece of code in section 2.2, it is seen that the axes are drawn by the use of two calls to the routine VEC. These are replaced by a single call to the routine AXESA. AXESA requires the coordinates of the origin and draws the axes from there. There is one disadvantage with AXESA, it draws the axes to the edge of the selected area and the effect of this can clearly be seen in 2.3.3. To improve the overall effect only requires the addition of a few more tick marks but it is left in this state to show how a system routine is a help but takes away some of the flexibility of using several less powerful routines to achieve the desired result.

Secondly, the sixteen calls used to label the axes (see the fourth piece of code in section 2.2) are replaced by a call to the routine SCALA. SCALA is described more fully in either the SMOG or the SPROGS manual, but it requires the following information: which points on the axes to label, what coordinates to label from, and the format these numbers should be in. In this example the labelling is started at (0.0,0.0) and X incremented by fifty and F(X) by three. The one point to notice about this routine is that the labels are in uniform increments and cover the whole of the visible area. Fortunately this is the effect that most users require.

2.3.1 Listing of source, file is GRAFEX.PROGRAM3

      MASTER EXAMPLE3
C---INITIALISE SYSTEM AND SELECT HARDCOPY
C---CAMERA IN "MANY-UP" MODE. 
      CALL FRHCM
C---SELECT THE "CINE" AREA. 
      CALL CINE
C---SET UP COORDINATE SYSTEM.
      CALL LIMITV (-20.0,-1.0,200.0,12.0) 
C---READ THE FIRST POINT.
      READ (1,5) X,FX 
    5 FORMAT (2F5.0)
      CALL SETXY (X,FX)
C---READ THE REMAINING 19 POINTS AND 
C---DRAW THE LINES. 
      DO 10 I=1,19 
      READ (1,5) X,FX 
      CALL TOXY (X,FX) 
   10 CONTINUE
C---DRAW THE AXES.
      CALL AXESA (0.0,1.0)
C---PUT TICK MARKS ON THE X-AXIS AND F(X)-AXIS. 
      CALL HGRATX (0.0,0.5,200.0,1.0,20) 
      CALL HGRATY (-5.0,1.0,0.0,10.0,9) 
C---CHOSE A CHARACTER SIZE.
      CALL CHSIZE (0.2)
C---OUTPUT A TITLE FOR THE GRAPH.
      CALL SETXY (70.0,11.0)
      CALL HTEXT (23,'GRAPH OF F(X) AGAINST X') 
C---LABEL X-AXIS. 
C---LABEL F(X)-AXIS.
      CALL SCALA (50.0,3.0,0.0,1.0,3.0,0.0,2.0,0.0) 
C---TERMINATE THE PLOTTING.
      CALL ENDSPR
      STOP
      END
****

2.3.2 Command obeyed to run job

This is almost identical to the one for section 2.2 but the program filename is different, see below:

TASK F,SMOG,*CR :GRAFEX.PROGRAM3,#CR :GRAFEX.PROG2DATA,JT30

2.3.3 FR80 output produced

Graph of F(X) against X

Graph of F(X) against X
Full image ⇗
© UKRI Science and Technology Facilities Council

2.4 Plot Y against X (The Easy Way)

In the majority of cases when plotting graphs, all that the user is worried about is the set of (X,Y) coordinates and suitable titles for the graph. It does not really matter what the numbers on the axes look like provided it is obvious which point is which. A routine has been written with this in mind and, appropriately, called GRAPH. The arguments required are as follows: the number of points to be plotted, arrays containing the X and Y coordinates of these points, the number of characters in the title and the text of the title, the number of characters and the text, in the X-axis title, and likewise for the Y-axis title.

In this example the X and Y values are set up using a DATA statement and as there are ten coordinates, the arrays X and Y have dimension ten. The hardcopy camera in "many-up" mode is chosen as the output device for this run and is selected by:

      CALL FRHCM 

The graph is plotted on the "cine" area with suitable titles as follows:

      CALL CINE
      CALL GRAPH(10,X,Y,12,'EXAMPLE FOUR',6,'X-AXIS',6,'Y-AXIS')

GRAPH sets up the limits using the data. The run is terminated as usual by:

      CALL ENDSPR

Some points to note about the text are: firstly, the arguments can just as easily be "variable" names if one remembers that each 1906A word stores four characters. To put the graph title in a variable NAME, say, will first require dimensioning NAME to 3, then the following DATA statement can be used to initialise the array:

      DATA NAME/'EXAM','PLE ','FOUR'/

Take care when using REAL arrays as each element is made up of two 1906A words, that is, eight characters. The second point about the text is that the title for the Y-axis occurs in a column and makes the hyphen look a little out of place (see 2.4.3).

GRAPH is available to users of SPROGS and SMOG but the output produced has some minor differences. In SPROGS, GRAPH uses software font number one whereas in SMOG it uses the selected hardware font. In other words, the characters are different but only if you look closely.

2.4.1 Listing of source, file is GRAFEX.PROGRAM4

      LIST
      MASTER EXAMPLE4
C
C    USE STANDARD ROUTINE TO PLOT A GRAPH.
      DIMENSION X(10),Y(10)
      DATA X/1.0,1,5,2.5,3.0,4,0,6.0,6.5,7.5,8.0,9.0/, 
     *Y/5.0,4.0,3.5,3.5,4.5,5.5,6.0,6.0,3.0,8.0/
C    SELECT HARDCOPY - MANYUP 
      CALL FRHCM
C    PLOT GRAPH ON CINE AREA 
      CALL CINE 
      CALL GRAPH (10,X,Y,12,'EXAMPLE FOUR',6,'X-AXIS',6,'Y-AXIS')
C    TERMINATE PLOTTING 
      CALL ENDSPR 
      STOP 
      END 
      FINISH

2.4.2 Command obeyed to run job

The job was run using SPROGS although SMOG could just have easily been, used. The GEORGE command obeyed when logged in was:

TASK F,SPROGS,*CR :GRAFEX.PROGRAM4,JT40

2.4.3 FR80 output produced

EXAMPLE FOUR

EXAMPLE FOUR
Full image ⇗
© UKRI Science and Technology Facilities Council

2.5 Plot Y1, Y2 And Y3 Against X

The problem is to draw several graphs one on top of the other and, as always, there are many ways to do this. This example illustrates several of these methods and like the previous example (2.4) the facilities required are available in SMOG or SPROGS. The graphs are three sets of Y coordinates initialised as arrays YARY1, YARY2 and YARY3. The X coordinates are in array XARY and all arrays are 10 elements long.

The routine GRAFT is used for multiple graphs, and like GRAPH, it sets up its own area and plots the set of points. Once the first graph has been drawn it is no longer necessary to draw the axes or tick marks but it is still possible to use GRAFT to plot subsequent sets of points. In the example the first set of points is plotted as a series of asterisks(*), the tick marks, labelling and axes are also plotted by the first call of GRAFT. In the second case GRAFT is used just to plot a series of minus signs (-) for the graph. The final graph is plotted as a series of lines joining each point.

For a full explanation of the options available in GRAFT see ([6] section 9.2.2) or ([5] section 5.10.2). As stated above, GRAFT is available in both SMOG or SPROGS and like GRAPH the two systems use different character sets to produce the annotation. The major difference between the two implementations of the graph drawing routines is caused by two factors. The first, as mentioned previously, is the two different character sets used. In the example, using the SPROGS character codes 39.0 and 37.0 for * and - respectively, produces graphs of Gs and Fs when run with SMOG on the 1906A. The other difference is caused by the SMOG system's only having one user region. As a result of this, option one of GRAFT does not function as expected and the GRAFRG routine has been modified so that whichever region greater than one is selected it refers in reality to region one. In the example, region 29.0 was used.

2.5.1 Listing of source, file is GRAFEX.PROGRAM5

      LIST
      MASTER EXAMPLE5
      DIMENSION XARY(10),YARY1(10),YARY200),YARY3(10) 
C---INITIALISE COORDINATES FOR GRAPHS
      DATA XARY/5.0,15.0,25.0,35,0,45.0,55.0,65.0,75.0,85.0,95.0/, 
     1YARY1/1.0,12.0,15.0,17.0,19.0,18.0,1 A.0,12.0,11.0,9.07, 
     2YARY2/10.0,8.0,11.0,13.0,12.0,10.0,7.0,5.0,3.0,1.0/ 
     3,YARY3/0.5,1.0,2.0,3.5,5.0,6.5,8.5,11.0,15.0,20.0/ 
C---SELECT THE HARDCOPY CAMERA AND 'CINE' AREA'.
      CALL FRHCM
      CALL CINE
C--SELECT A SUITABLE REGION FOR THE GRAPHS.
      CALL GRAFRG (29.0) 
C---DRAW FIRST GRAPH. USE * AS PLOTTING SYMBOL.
      CALL GRAFT (2,10,XARY,YARY1,1.0,1.0,39.0) 
C---DRAW SECOND GRAPH. USE - FOR POINTS.
      CALL GRAFT (4,10,XARY,YARY3,0.0,6.0,38.0) 
C---DRAW THIRD GRAPH ON THE SAME GRID. CONTINUOUS LINE.
      CALL SETXY (XARY(I),YARY2(I))
      DO 100 I=2,10
      CALL TOXY (XARY(I),YARY2(I))
  100 CONTINUE 
C---TITLE GRAPH
      CALL TITLAB (15,'MULTIPLE GRAPHS',6,'X-AXIS',6,'Y AXIS') 
C---FINISHED PLOTTING SO INFORM THE SYSTEM.
      CALL ENDSPR
      STOP
      END

2.5.2 Command obeyed to run job

The program was run using the SPROGS system and the command issued when logged in was as follows:

TASK F,SPROGS,*CR :GRAFEX.PROGRAM5,JT40

2.5.3 FR80 output produced

MULTIPLE GRAPHS

MULTIPLE GRAPHS
Full image ⇗
© UKRI Science and Technology Facilities Council

2.6 Plot a Histogram Y Against X

This section describes the use of the routine HSTGMA which plots a histogram. The user not only determines the shape of the histogram but also what type of shading is to be used, HSTGMA can be called from either SPROGS or SMOG and in the example that follows SMOG is used.

For the example 10 values of Y are chosen and the increment in the X direction is set to 10 units. This means that the histogram 100 units wide. The origin for the histogram is set to (0.0,0.0) and the maximum Y value is just over 80 units.

As with most of the examples, the "cine" area of the "many-up" hardcopy camera is selected. The limits of this area are chosen so that at the top, bottom and left, a gap of 20 units is left for appropriate titles:

      CALL LIMITV(-20.0,-20.0,100.0,100.0) 
C---PLOT THE HISTOGRAM.

The Y values for the histogram are initialised in a DATA statement and are in an array called YVALUE. The routine HSTGMA has the following arguments: origin of histogram (set to 0.0,0.0), the interval in the X direction (set to 10.0), the array of Y values and the number of Y values (YVALUE,10.0), the line spacing and type of shading to be used (2.0,2.0,6.0), and the type of border to use (1.0 to include baseline). The complete argument list is used as follows:

C---PLOT THE HISTOGRAM.
      CALL HSTGMA(0.0,0.0,10.0,YVALUE,10.0,2,0,2.0,6.0,1.0)

There are three points to notice about the text used for titling.

  1. Type of text - hardware text is used because SMOG does not have any software fonts. The default font is acceptable and saves the user's having to select a font (at the time of writing only two fonts were available on the FR80 ([6] section 6.3.2).
  2. Size of text - the text size was set to 3 units, the plotting area had previously been set up with a Y range of 120 units and thus 40 characters maximum for a line of text in the Y direction. As the "cine" area is in a three to four ratio the maximum number of characters in the X direction is just over fifty.
  3. Angle of text - the FR80 can rotate the hardware text by multiples of forty-five degrees. To select which octant the text should be in, the routine CHOCT(R) is used. R=0.0 selects normal text (across the page) and is' the default setting. Each unit increment of R rotates the text forty-five degrees anti-clockwise. In the example text is written down in the left margin. To do this, call CHOCT with R=6.0.. If any more text is to be output one should remember to call CHOCT with R=0.0 to return the text to normal orientation.

The plotting is now complete and all that remains is to call ENDSPR to tell the system that the plotting is finished. The listing of the source, how it was executed and the resultant FR80 output are shown below.

2.6.1 Listing of source, file is GRAFEX.PROGRAM6

      LIST
      MASTER EXAMPLE6
C---PROGRAM TO PRODUCE A HISTOGRAM.
      DIMENSION YVALUE(10)
      DATA YVALUE/20.0,35.0,42.0,54.0,75.0,81.0,79.0,67.0,57.0,32.O/ 
C---SELECT HARDCOPY AND CHOSE LIMITS
      CALL FRHCM
      CALL CINE
      CALL LIMITV (-20.0,-20.0,100.0,100. 0) 
C---PLOT THE HISTOGRAM.
      CALL HSTGMA (0.0,0.0,10.0,YVALUE,10.0,2.0,2.0,6.0,1.0) 
C---USE HARDWARE CHARACTERS FOR TITLE AND LABELS.
      CALL CHSIZE (3.0)
      CALL SETXY (20.0,90.0)
      CALL HTEXT (21,'EXAMPLE 6 A HISTOGRAM')
      CALL SETXY (20.0,-10.0)
      CALL HTEXT (21,'COLUMNS 10 UNITS WIDE')
      CALL CHOCT (6.0)
      CALL SETXY (-10.0,70.)
      CALL HTEXT (21,'SHADING EVERY 2 UNITS') 
C---TERMINATE THE PLOTTING.
      CALL ENDSPR
      STOP
      END

2.6.2 Command obeyed to run job

The job was issued using TASK. When logged in the command is as follows

TASK JT30,SMOG,*CR :GRAFEX.PROGRAM6

Note that F can be omitted as FORTRAN is the default for TASK.

2.6.3 FR80 output produced

EXAMPLE 6: A HISTOGRAM

EXAMPLE 6: A HISTOGRAM
Full image ⇗
© UKRI Science and Technology Facilities Council

2.7 Plot A Multiple Histogram

A multiple or composite histogram allows several values of Y for each value of X. The routine CMHSTA, allows each set of Y values to be associated with a different type of shading. The maximum height for the histogram is the sum of the maxima for each set of Y values; limits should be chosen accordingly. CMHSTA is available to both SMOG and SPROGS users but this example of its use will only work with SPROGS owing to the inclusion of software text. The arguments to this routine are similar to those for HSTGMA, see section 2.6, but where necessary several values are needed because there is more than one set of Y values.

The arguments passed to CMHSTA (see line thirteen of the source in section 2.7.1) are: the origin of the histogram (set to 0.0,0.0), the X interval in user coordinates (set to 10.0), the array of Y values, the number of Y values in each set and the number of sets of Y values (DATAR, 10.0,3.0 where, DATAR(1) to DATAR(10) is the first set, DATAR(11)-(20) the second and DATAR(21)-(30) the third), three arrays containing the line spacing and type of shading used for each set (DX,DY,TYPE where DX and DY were set to 2.0 for all three sets of Y values and TYPE was set to 3.0, 6.0 and 1.0, rectangular cross-hatchings, diamond cross-hatching and horizontal line shading respectively), and the type of border to use (set to 0.0 so as to exclude the baseline).

In the example (see below) the arrays passed to CMHSTA are suitably dimensioned and then initialised using data statements. The maximum value Y can have is 25+30+5=60 and X has a maximum of 100. The limits chosen were sufficiently greater than this to allow room for some titling. The cine area of "many-up" hardcopy was set to (-5,-10), (105,110) as follows:

C---SELECT THE HARDCOPY CAMERA IN 'MANY-UP1 and CHOOSE LIMITS 
      CALL FRMCM 
      CALL CINE 
      CALL LIMITV(-5.0,-10.0,105.0,110.0)

The composite histogram has three sets of Y values and these are plotted as follows:

C---PLOT THE COMPOSITE HISTOGRAM .
      CALL CMHSTA(0,0,0.0,10.0,DATAR,10.0,3.0,DX,DY,TYPE,0.0)

Software text is used for the labelling and titles. Font number one is selected (for font definitions see [4] appendix 7). The text is defined on a 16 × 16 grid but this is much too large for the currently selected limits. At this stage one can either redefine the limits or adjust the size of the text. The latter course was chosen in the example and the text was reduced to a fifth of the size, by TEXPAN(0.2,0.2), allowing just over 30 characters per line across the plotting area.

The scale is plotted along the X-axis by the use of the routine SCALA. To prevent any scaling on the Y-axis, the increment along that axis is set to zero ([5] 5.11). If one refers to the FR80 output in section 2.7.3 it can be seen that the limit chosen for maximum X was not quite large enough for the number '100'. This fault is left in to illustrate one of the problems when using SCALA. As stated in ([4] A11) this routine labels the axes from the origin to the edge of the region at the specified step length. In the example the origin is (0.0,0.0) and the step length in the X direction is 10.0. If one increases the limit for maximum X from 105.0 to 110.0 it will plot the '100' alright but will now attempt to plot '101' as well. The obvious solution is to choose a value like 108.0 for the maximum X limit.

The title is output using the TEXT routine and each string is positioned using SETXY. To calculate a suitable X value, for centred text, one has to take the length of the string and the character size into account. For the first line in the example there are 9 characters all 3.2 units wide. The centre of the histogram is 50 units which gives a sum of 50-9 × 1.6 = 35.6 for the start of the string. Finally, as usual, ENDSPR must be called.

2.7.1 Listing of source, file is GRAFEX.PROGRAM7

LIST
      MASTER EXAMPLE?
      DIMENSION DATAR(30),TYPE(3),DX(3),DY(3) 
C---THIS PROGRAM OUTPUTS SEVERAL HISTOGRAMS TOGETHER.
      DATA TYPE/3.0,6.0,1.0/,DX/2.0,2.0,2.0/,DY/2.0,2.0,2.0/ 
      DATA DATAR/10.0,21.0,12.0,18.0,14.0,25.0,16.0,20.0,8.0,14.0, 
     110.0,20.0., 10.0,20.0,10.0,20.0,30.0,20.0,30.0,20.0,10*5.0/
C---SELECT THE HARDCOPY CAMERA IN 'MANY-UP' AND CHOOSE LIMITS
      CALL FRHCM
      CALL CINE
      CALL LIMITV (-5.0,-10.0,105.0,110.0) 
C---PLOT THE COMPOSITE HISTOGRAM.
      CALL CMHSTA (0.0,0.0,10.0,DATAR,10.0,3.0,DX,DY,TYPE,0.0) 
C---USE SOFTWARE CHARACTERS FOR LABELLING ETC.
      CALL GETFNT (1.0)
      CALL TEXPAN (0.2,0.2)
      CALL SCALA (10.0,0.0,0.0,0.0,2.0,0.0,0.0,0.0)
      CALL SETXY (35.6,100,0)
      CALL TEXT (9,'EXAMPLE 71)
      CALL SETXY (16.4,90.0)
      CALL TEXT (21,'A COMPOSITE HISTOGRAM') 
C---TERMINATE THE PLOTTING.
      CALL ENDSPR
      STOP
      END

2.7.2 Command obeyed to run job

Note that because of the use of software text, the example will only run using SPROGS. The command when logged in at MOP was:

TASK F,SPROGS,*CR :GRAFEX.PROGRAM7,JT35

2.7.3 FR80 output produced

EXAMPLE 7: A COMPOSITE HISTOGRAM

EXAMPLE 7: A COMPOSITE HISTOGRAM
Full image ⇗
© UKRI Science and Technology Facilities Council

2.8 Contour Plotting

A contour plot is a method of representing a three-dimensional surface in two dimensions. Each contour line represents points of equal height just like the contour lines on maps. The contour routine used for the example in this section, CNTR2A, requires the three-dimensional surface to be represented by a grid of x and y coordinates and, at each grid point, a height. From these values the contour routine then calculates lines of equal height and plots them.

2.8.1 An example from physics

Consider two isolated point charges A and B with normalised values -1 and -2 respectively. Let the two points be located in a reference plane with A at (4.1,10.05) and B at (14.1,5.9). The potential at a point P, (X,Y), in this plane is given by the expression

-(1/DA + 2/DB) 

where DA and DB are the distances of A and B from P, respectively.

The potential is calculated on a square grid at all points (x,y) where x = 1,2,.... 20 and y = 1,2,... 20. The potential at the points A and B is infinite and thus A and B must not be grid points; at the same time they must be fairly close to grid points to prevent too large a rounding error creeping in. In the program the potentials are calculated and stored in the two-dimensional array POT.

2.8.2 The contour plot

The contouring routine CNTR2A (A2GRID,A2WORK,L,M,N,A1CONT,NUMCNT) plots on an area N points by M points, and relies on the user having set his output region to at least (0.0,0.0) to (N-1,M-1). In the example this would be (0.0,0.0) to (19.0,19.0) but a small margin is left around the edge. The following three calls select the "cine" area of the FR80's hardcoy camera in "many-up" mode and set the user coordinates for this area:

      CALL FRHCM
      CALL CINE
      CALL LIMITV(-2.0,-2.0,22.0,22.0)

If the user does not wish to use CNTR2A in the default mode of operation ([7] section 1.3) it is possible to alter parameters in the option COMMON block CNTOPT. If the default mode of operation is satisfactory then there is no need to include this COMMON block. In the example two variables were changed; firstly, because the output is to "many-up" hardcopy the character size is a bit small, requiring a change to one and a half times the standard size; secondly, the option of allowing user specification of the contour heights was switched on.

The arguments of CNTR2A in the example are (POT,WORK,20,20,20,HEIGHT,5) where: POT is the two dimensional array containing the grid point potentials; WORK is a logical array dimension (M,N) used by CNTR2A for workspace; 20 is the first dimension of POT because in this example the grid fills all of the array POT; 20 and 20 are the number of grid points in the y and x directions respectively. HEIGHT is an array containing the contour heights that are to be plotted and 5 is the number of contours. When the contours are plotted they are labelled in the range one to NUMCNT, in this case 5. To find out the actual value for these contours it is necessary to look the labels up in a key. The key is automatically output to a lineprinter file by CNTR2A and, if required, it can be plotted as well. To plot the key to the contours use the routine CNTKEY(XP,YP,A1CONT,I,J) where (XP,YP) defines the position of the top left corner of the key, A1CONT is the same as for CNTR2A, I and J are the first and last contours to be included in the key. In the example CNTKEY is called with the following arguments; (-2.0,21.5, HEIGHT,1,5) in this way all the contour heights are listed at the top left corner of the frame. It should be possible to adjust the limits of the region and (XP,YP) so as to plot the key completely outside the contour grid or to plot the key on a separate frame but these are left as an easy exercises for the reader.

2.8.3 Listing of source, file is GRAFEX.PROGRAM8

      LIST
      MASTER CONTOR
      DIMENSION POT(20,20),HEIGHT(5) LOGICAL WORK(20,20)
      DATA X1,Yl,X2,Y2/4.1,10.5,14.1,5.9/ 
     *,HEIGHT/0.5,1.0,2.0,4.0,8.0/
C***********************************************************************
C   CHOOSE CONTOURING OPTIONS
C********************************************************************
C  ALTER VALUES IN COMMON BLOCK CNTOPT TO CHANGE 
C  DEFAULT SETTINGS. A COPY OF THE COMMON BLOCK IS KEPT 
C  AS FILE :GRAFLIB.CONTOURS-COM, THIS IS TO SAVE USERS 
C  THE BOTHER OF TYPING IT IN. TO ALLOW USER CHOICE OF 
C  CONTOUR HEIGHTS SET ICH TO 1. SET RELATIVE CHARACTER 
C  HEIGHT RCH TO 1.5.
C
*INCLUDE(*CR,:GRAFLIB.CONTOURS-COM)
      ICH=1
      RCH=1.5 
C
C   CHANGE THE OUTPUT STREAM FROM THE DEFAULT OF 98 TO 6. 
C
      CALL LIBOP (6)
C**************************************************
C  CALCULATE POTENTIALS
C************************************************
C
C THE HEIGHTS ARE ON A LOG SCALE, THEREFORE THE SLOPE 
C IS STEEPER THAN IT FIRST APPEARS.
C 
C THE POINT CHARGES ARE LOCATED SO AS TO PREVENT THE 
C INFINITE POTENTIALS FROM FALLING ON THE GRID POINTS.
C
C LOOP TO CALCULATE POTENTIALS ON EACH GRID POINT
C
      DO 1 I=1,20 
      A=1
      A1=(A-Y1)*(A-Y1) 
      A2=(A-Y2)*(A-Y2)
      DO 2 J=1,20 
      B=1
      POT(I,J)=1/SQRT(A1+(B-X1)*(B-X1))+2/SQRT(A2+(B-X2)*(B-X2)) 
    2 CONTINUE 
    1 CONTINUE
C-******ft***************************************************
C  PLOT CONTOUR MAP
C-**********************************************************
C
C   SELECT 'MANY-UP* HARDCOPY IN CINE MODE
C  CHOSE LIMITS SLIGHTLY LARGER THAN CONTOUR GRID
      CALL FRHCM
      CALL CINE
      CALL LIMITV (-2.0,-2.0,22.0,22.0) 
C  PLOT CONTOURS
      CALL CNTR2A (POT,WORK,20,20,20,HEIGHT,5) 
C  OUTPUT THE KEY TO THE CONTOURS.
      CALL CNTKEY (2.0,21.5,HEIGHT,1,5) 
C  TERMINATE PLOTTING
      CALL ENDSPR
      STOP
      END

Note:

*INCLUDE (see[2] L3.2.6) adds the COMMON block CNTOPT, stored as file :GRAFLIB.CONTOURS-COM, to the program.

The call to LIBOP(6) re-routes the contour key listing from LP0 (stream 98) to LP9 (stream 6).

2.8.4 Command obeyed to run job

The contouring routines used in this example reside in the graphics library :GRAFLIB.GRAFLIB, they are put there because they are not an integral part of SMOG or SPROGS but can be used from either. This means that only one copy of each routine is required. To access this library an additional TASK parameter is required, it is:

LIB :GRAFLIB.GRAFLIB

To run the job one could issue the following command when logged in:

SMOG *CR :GRAFEX.PROGRAM8,LIB :GRAFLIB.GRAFLIB,JT30,*LP,#LP6,#LP9 KEYLIST

The LP parameters are included because by this stage if one has run all of the examples so far then it is very likely that one is fed up with the three separate listings each job produces. The ALP will cause the compilation and consolidation listings to be merged with the monitoring file and the #LP6 causes the FR80 user listing (for example, which camera has been used) to be included as well. The #LP9 KEYLIST is to ensure that the listing of the keys produced by CNTR2A is not added as well but stored in the file KEYLIST until required. A listing of KEYLIST is shown in section 2.8.6.

2.8.5 FR80 output produced

Contour Plot

Contour Plot
Full image ⇗
© UKRI Science and Technology Facilities Council

2.8.6 Output from CNTR2A, File is :GRAFEX.KEYLIST

SUBROUTINES CNTR2A HAS BEEN ENTERED
===================================
THE VALUES OF THE VARIABLES IN THE OPTION COMMON BLOCK HAVE BEEN CHECKED
THE VALUES ARE :-
    OPTION           VALUE
     ICON              2
     ICH               1
     DX          0.0000000E 00
     DY          0.0000000E 00
     RCOS        0.0000000E 00
     IBOX              1
     IGR               0
     ILAB              1
     RFR         0.1000000E 01
     RCH         0.1500000E 01
     IT                0
     IDF               0
     RLV         0.0000000E 00
     
THE CONTOURS DRAWN ARE :-
   CONTOUR NO   CONTOUR HEIGHT         NO DRAWN
      1          0.5000000E 00             1
      1          0.1000000E 01             2
      1          0.2000000E 01             2
      1          0.4000000E 01             2
      1          0.8000000E 01             2
⇑ Top of page
© Chilton Computing and UKRI Science and Technology Facilities Council webmaster@chilton-computing.org.uk
Our thanks to UKRI Science and Technology Facilities Council for hosting this site