[UP]


Manual Reference Pages  - graph (3)

NAME

graph(3) - [M_graph] Draw an XY graph

CONTENTS

Synopsis
Description
Options
Example
Author

SYNOPSIS

subroutine graph(x,y,ndp,ndl,f,c,nc)

DESCRIPTION

This is an XY graph routine that is intended to be very self-contained and easily ported to various graphics libraries. This version is callable from the M_draw(3f) module.

It is being ported from the LONGLIB public domain library and will be changing. It is recommended that you rename the M_graph(3f) module source to freeze a copy at this point, as new versions will not necessarily be upward compatible. The underlying calls to M_graph(3f) should not require any changes.

graph(3f) is a general routine for plotting lines or scatterplots. Optionally, error bars and symbols can be added. graph(3f) differs in philosophy from other libDL MASTER routines in that plotting options are passed via an option array. The routine is designed to produce a reasonable plot with the option array set to all zeros. The output format is changed by initializing selected array elements to the values described below. This permits simple but flexible specification of the plot format.

OPTIONS

x (R): x input array dimensioned x(ndp,ndl).
y (R): y input array dimensioned y(ndp,ndl).
ndp (i): number of data points per line
ndl (i): number of data lines
f (R): option array dimensioned at least f(53)
              (described below)
c (C): array of strings dimensioned C(3+ndl)
               c(1) : x axis title
               c(2) : y axis title
               c(3) : top title
               c(4) : line 1 legend (optionally used)
               c(5) : line 2 legend (optionally used)
               ...        ...
nc (i): array of string lengths dimensioned nc(3+ndl)
               nc(1) : number of characters to use in C(1)
               nc(2) : number of characters to use in C(2)
                ...       ...

The array elements of the option array f are interpreted according to the following table. Some parameters have default values (shown in square brackets). These are used when the input value is zero. A simple plot may be produced by setting all the elements of f to zero. Note that user specified input scaling factors should be powers of ten when the log axis specification is selected. An optional legend may be plotted. The legend consists of a column of lines and the labels from n(4:)
     array  range of
     index  values   action for each value
------- -------- ------------------------
 
1 0<=.<=ndp number of points/line to plot [ndp]: 0=ndp used
2 0<=.<=ndl number of lines to plot [nl]: 0=ndl used
3 -1/0/1 x scale: 0=auto,smoothed; 1=auto,nosmooth; -1=user
4 xmin user supplied scale value (used if f(3)<0)
5 xmax user supplied scale value (used if f(3)<0)
6 -1/0/1 y scale: 0=auto,smoothed; 1=auto,nosmooth; -1=user
7 ymin user supplied scale value (used if f(6)<0)
8 ymax user supplied scale value (used if f(6)<0)
9 0/1 x value usage: 0=first line of x data array used for all y lines; 1=lines of x,y paired
10 0/1 connect plotted points: 0=yes; 1=no
11 >=0 symbol plotted every ()th point: 0=no symbols
12 >=0 line symbol size [0.1]: 0=use default
13 >=0 symbol number for first data line, each line then uses next symbol in sequence
14 8<.<8 error bar option (see below): 0=no error bars
16 >=0 error bar size [0.1]: 0=default used
17 0/1 vertical line from points to reference value: 0=no; 1=yes
18 rval reference value
19 -1/0/1 x axis type: 0=linear; 1=log axis, -1=no axis
20 -1/0/1 y axis type: 0=linear; 1=log axis, -1=no axis
21 >=0 x axis length [7.0]: 0=default used
22 >=0 y axis length [5.0]: 0=default used
23 >=0 x axis tick pattern (see axisc_) [7.00]: 0=default
24 >=0 y axis tick pattern (see axisc_) [5.00]: 0=default
25 0/1 x axis title side of axis: 0=below; 1=above
26 0/1 y axis title side of axis: 0=left; 1=right
27 0/1 x axis auto exponent enable: 0=enable; 1=disable
28 0/1 y axis auto exponent enable: 0=enable; 1=disable
29 0/1 x axis tick side: 0=below; 1=above
30 0/1 y axis tick side: 0=left; 1=right
31 0/1 x axis number orientation: 0=horizontal; 1=vertical
32 0/1 y axis number orientation: 0=vertical; 1=horizontal
33 0/1 x axis numbers/title: 0=shown; 1=not shown
34 0/1 y axis numbers/title: 0=shown; 1=not shown
35 0/1 use x=log10(abs(x values)+1.e-34): 0=no; 1=yes
36 0/1 use y=log10(abs(y values)+1.e-34): 0=no; 1=yes
37 -1/0/1 add mirror x axis: 0=no; 1=w/labels; -1:w/o labels
38 -1/0/1 add mirror y axis: 0=no; 1=w/labels; -1:w/o labels (mirrored axes placed on opposite from normal axis)
39 >=0 x axis label size [0.15]: 0=use default
40 >=0 y axis label size [0.15]: 0=use default
41 >=0 top title character size [0.18]: 0=use default
42 0/1/2/3 grid: 0=no grid; 1=solid; 2=dotted; 3=ticked
43 -1/0/1 legend: 0=no legend; 1=right side; -1=user locate
44 xval user specified lower-left corner of legend
45 yval user specified lower-left corner of legend
46 0/1 show plot symbol on legend: 0=no; 1=yes
47 0/1 show line segment on legend: 0=no; 1=yes
48 >=0 legend character height [0.12]: 0=use default
49 >=0 legend line segment length [0.5]: 0=use default
50 -1/0/1 top title justify: 0=center; -1:left; 1:right
51 0/1 plot horizontal reference line: 0=no; 1=yes
52 0/1 use linetype array values: 0=no; 1=yes
53 0/1 use color array values: 0=no; 1=yes
54 >=0 color index #1: 0=color value 1 used
55 >=0 linetype index #1
56 >=0 color index #2: 0=color value 1 used
57 >=0 linetype index #2
...
The optional error bar specification, when non-zero, changes interpretation of lines. The first line (and every third line) is considered a "center" line. The second line specifies the relative error (to be added to the first line) used for plotting the tops of the error bars. The third line is used similarly to locate the bottoms of the error bars. When the error bar specification is negative the center line points are marked with a special "x" (in addition to any other option). The absolution value of the specification determines the type of error bar according to the following table.

    value   type of error bar
    ------  ---------------------------------------------------
     1     line connecting relative errors
     2     1 + horizontal bars at relative errs
     3     1 + vertical bars at relative errs
     4     double line connecting rel. errs+horizontal bars
     5     double line connecting rel. errs+vertical bars
     6     vertical rectangle w/top and bottom rel. errs
     7     rectangle with corners at relative errors

The color and line type index (when enabled) are used according to the following table.

    index #        color usage     linetype usage
    ---------      -------------   ----------------
      1              x axis         x axis
      2           x axis numbers    y axis
      3           x axis title      title
      4           x axis exponent   legend titles
      5              y axis         reference line
      6           y axis numbers    error bars
      7           y axis title      line #1 linetype
      8           y axis exponent   line #2 linetype
      9              title            etc.
     10             legend titles     ...
     11            reference line     ...
     12               grid            ...
     13             line #1 color     ...
     14             line #2 color     ...
     ...            ... etc. ...      ...

EXAMPLE

Sample program that creates some simple curves and then prompts for index values and values in the options array to allow for testing various options.

   program demo_graph
   use m_graph, only : graph, graph_init
   use M_draw

integer,parameter :: numlines=3 integer,parameter :: numpts=25 integer,parameter :: nf=255 real :: x(numpts),y(numpts,numlines) character(len=80) :: c(numlines+3) integer :: nc(numlines+3) real :: f(nf) character(len=20) :: device integer :: ixsize integer :: iysize character(len=:),allocatable :: filename integer :: w device=’x11’ ixsize=1200*.75*0.5 iysize=900*.75*0.5 w=40 if(device.eq.’x11’)then call prefposition(0,0) call prefsize(ixsize,iysize) else call prefsize(ixsize,iysize) !!call voutput(str(filename,’_’,int(a),’x’,int(b),’.’,device,nospace=.true.)) endif call vinit(device) call vsetflush(.false.) call vflush() call linewidth(w)

! fill some arrays with data we can plot DO i20=1,25 X(i20)=i20 Y(i20,1)=i20**2+5.0 Y(i20,2)=i20*20.0 Y(i20,3)=(-3.0)*(i20/4.0)**3 enddo

f=0.0 ! zero out option array ! set up color and linetype in option array do i70=55,nf,2 f(i70)=mod(i70,7) f(i70-1)=mod(i70,7) enddo f(52)=1 f(53)=1

ndp=numpts! number of data points per line ndl=3 ! number of data lines !c ! array of strings dimensioned c(3+numpts) c(1)=’X-AXIS’ ! c(1) : x axis title c(2)=’Y-AXIS’ ! c(2) : y axis title c(3)=’TITLE’ ! c(3) : top title c(4)=’LABEL 1’ ! c(n) : line N-3 legend (optionally used) c(5)=’LABEL 2’ ! c(n) : line N-3 legend (optionally used) c(6)=’LABEL 3’ ! c(n) : line N-3 legend (optionally used) !nc ! array of string lengths in c() dimensioned nc(3+numpts) do i60=1,6 nc(i60)=len_trim(c(i60)) enddo !f(39)= 0.25 !f(40)= 0.25 !f(42)= 3.00 !f(43)=-1.00 ! initialize graphics call graph_init(12.0,9.0, 1.00,1.00, 1.0) INFINITE: do CALL graph(X,Y,NDP,NDL,F,C,NC) call vflush() 888 continue write(*,*)’Enter index and value for graph(3f) option array:’ read(*,*,end=999,err=888)index,value if(index.lt.1)then exit INFINITE elseif(index.gt.nf)then goto 888 else f(index)=value write(*,*)’index ’,index,’ now ’,value endif call vflush() ! flush graphics buffers call color(7) call clear() call color(0) call vflush() ! flush graphics buffers enddo INFINITE 999 continue call vflush() ! flush graphics buffers call vexit() ! close up plot package stop end program demo_graph

AUTHOR

Based on [LONGLIB93.SOURCES.FORTRAN.MASTER]graph.FOR
! WRITTEN: Version 1.0 SEPT. 1987 - DGL Version 2.0 20-JAN-1994 17:13:12.80 Version 3.0 Wed Jun 12 10:34:11 MDT 1996


graph (3) March 11, 2021
Generated by manServer 1.08 from bb84843e-9c2c-45df-b4f3-7734a342b973 using man macros.