download plotit.tar from here
In its current (May 2003) version, I have altered the guts of PLOTIT so that it no longer relies on the XVIEW graphics libraries, an obsolete set of subroutines introduced by Sun Microsystems more than 15 years ago. Instead, PLOTIT relies on simple XLIB routines, and has been developed and tested with the X11R6 libraries that come with RedHat Linux (On a Dell Workstation) and the XDarwin package in MacOS X (10.1.5, I havent tried Jaguar yet). Since X11 lies at the bottom of the X-window environments that I know about, this means that the code should be portable to most flavors of Unix. There is a link to mirror page for Xview version of PLOTIT -- this version is no longer available.
PLOTIT can also create graphs of quite respectable quality. If asked to, the routine will write out a postscript plotfile for hardcopy output. The postscript commands are almost entirely "moveto" and "drawto" commands, because PLOTIT was written in the middle 1980s for a simple penplotter. The PS file is very primitive, especially for people who have waded through a GMT output file. You could import it into some other graphics application program to transition it to EPS format. Most of the PLOTIT code, in fact, consists of common blocks with coded instructions on how to draw letters and symbols. Very retro. Each PS file has a set of commented commands for writing text on the plot with honest PS fonts. The lineweight command is near the top of the file, so that you can change it. There are also comment lines that delineate the drawn letters, so that you can remove them. Ghostview jockeys can therefore customize PLOTIT output for presentation graphs.
COMPILATION Issues
PLOTIT was adapted from PLOTXY, written at Scripps Institution of Oceanography by Robert Parker and Loren Shure (Loren's prelude to MATLAB design!). It was adapted by Jeffrey Park for MicroVMS in 1987 with the help of Ted Fischer and Fred Kagan. I converted PLOTIT to Sun Xview commands in 1991, and have modified the code to work with the GNU-project gcc and g77 compilers in RedHat Linux and MacOS X with XDarwin. Such a long parentage makes for a complicated code. It comes to you without warranty. Over the years I have tweaked some of the input parameters for symbol size, etc, so some "features" may be unexpected for you. These might crop up when using MODE=4 or MODE=5. However, PLOTIT is all about quick and dirty lineplots, and the code should work as documented for such cases. When you unpack the tar file, you get plotit.f, manyplot.f, makedat.f and xlplotit.c. manyplot.f is a driver for PLOTIT that organizes plotting of mutiple traces. makedat.f is a program that generates some random data and plots it in different ways. xlplotit.c contains C-routines that actually do the low-level X-management.
PLOTIT expects a 3-button mouse. Check your Apple documentation for how to emulate one
suggested compilation
cc -c -I/usr/X11R6/include -L/usr/X11R6/lib
-lX11
xlplotit.c
f77 -c -I/usr/X11R6/include -L/usr/X11R6/lib
-lX11 plotit.f manyplot.f
ar r plotlib.a xlplotit.o plotit.o manyplot.o
ranlib plotlib.a
TO COMPILE AND LINK makedat.f
f77 -o makedat -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 makedat.f plotlib.a
You can substiture for the location of the X11R6 directories on your system, natch.
NOTE -- the GNU fortran compiler is very persnickety about the bounds of arrays passed to subroutines. You will get a lot of compilation warnings, because I use the array(1) convention to avoid prespecifying array sizes. The code should work despite compilation warnings of this type. If you start to monkey around with the common blocks, you have gone over to the Dark Side. However, small fixes can sometimes be useful (like shrinking the data array sizes if your computer cant dynamically allocate space)
USING PLOTIT
REMEMBER: input data must be REAL*4 --> if you try to plot REAL*8 arrays, your computer will EXPLODE.
One can plot smooth curves, symbols, symbols with error bars, etc., all on the same graph. PLOTIT also draws axis labels and a title in a choice of four fonts with optional sub/super- scripting, Greek letters and many mathematical symbols. Data can be plotted log-log, lin-log, log-lin, or lin-lin.
calling sequence:
call plotit(xdat,ydat,dydat,npts,iitit,iixlab,iiylab,mode,logg, adash,isymbl,ipnow)
input variables:
XDAT - array of x-ordinates (real*4) 300k points allowed(!)
YDAT - array of y-ordinates (real*4)
DYDAT - array (real*4) of error sizes or symbol sizes, depending on MODE note: if MODE=1 or 2, DYDAT can just be a dummy variable with no dimension
NPTS - number of points to plot (int*4)
IITIT - character string with plot title
IIXLAB - character string with the x-axis label
IIYLAB - character string with the y-axis label
note: PLOTIT will crash if IITIT, etc. are zero length. If a title or an axis label is not desired, enter '|space|' as input rather than ''.
MODE - type of plot (int*4)
1 -> even spaced x values, XDAT(1)=x0,XDAT(2)=dx
2 -> x-y pairs
3 -> x-y pairs, error bars in y
-3-> x-y pairs, error bars in x
4 -> plot symbols at x-y pairs defined by XDAT and YDAT, with relative symbol sizes given in DYDAT. PLOTIT will plot different symbols for positive and negative values of DYDAT. This option allows PLOTIT to emulate a poor man's contouring program, at least for modest data sets.
5 -> symbols at x,y, symbols size (>0) in dydat, user-chosen symbol
LOGG - data scaling parameters (int*4)
0 -> linear x, linear y
1 -> log x, linear y
2 -> linear x, log y
3 -> log x, log y
ADASH - plotting style or symbol size (real*4)
if MODE < 4
if ISYMBL = 0
ADASH = 0 ==> smooth curve
ADASH > 0 ==> dashed lines with dashes of length ADASH inches
if ISYMBL >0
ADASH = 0 ==> default symbol size (.3 inches)
ADASH > 0 ==> symbol size in inches (roughly)
if MODE = 4
ADASH = 0 ==> default symbol size maximum (.3 inches)
ADASH > 0 ==> symbol size mazimum in inches
NOTE: Don't use ADASH < 0.
ISYMBL - 0 -> plot data as a smooth curve (int*4)
>0 -> plot data with symbols with symbol type ISYMBL
symbol types:
| 1 -> square
2 -> triangle 3 -> octagon 4 -> diamond 5 -> plus sign 6 -> asterisk 7 -> cross ('x') 8 -> slashed square 9 -> upward arrow 10 -> hourglass 11 -> campstool |
12 -> hexagon
13 -> 'y' 14 -> vertical bar 15 -> Star of David 16 -> small dot 17 -> small circle 18 -> circle 19 -> large circle 20 -> small filled disk 21 -> small filled square 22 -> small filled triangle |
IPNOW - plot now or wait for more data to plot (int*4)
0 -> wait for more data
1 -> plot one graph now
The 0-option is used to plot traces on top of each other, perhaps one dashed, the other continuous, sometimes with data plotted as symbols, the model prediction plotted with a smooth curve, and so on. After a plot is generated, PLOTIT flushes its data buffers, discarding the previous plotting information.
IPNOW can also command PLOTIT to draw up to six graphs on a page For instance, if four plots are desired, call PLOTIT once for each graph,
IPNOW=41 for the first graph,
IPNOW=42 for the second graph
IPNOW=43 for the third graph
IPNOW=44 for the last graph
PLOTIT will close any output files and wait for a carriage return to continue after the IPNOW=44 call. There is no pause in execution until then. More than one curve can be plotted on any one of the graphs by calling plotit with IPNOW=0 for the first datasets, IPNOW=nn for the last in a given graph. Test it to see how the logic works if you wish to try something complicated. You cannot close the output file until you have called PLOTIT with IPNOW=22 or 33 or 44 or 66. (Note: for some reason PLOTIT doesnt like 5 plots on a page and I am too lazy to find out why)
PLOTIT will self-scale the data to be plotted. The user can override self-scaling by accessing, in the routine that calls PLOTIT, the common block
common/paramp/xlen,xlim(2,6),ylen,ylim(2,6)
All variables are real*4. XLEN and YLEN define the size of the plot and are not easy to tinker with. XLIM and YLIM are all zero-valued by default, which instructs PLOTIT to self-scale the input data. The user can impose limits on the plot e.g. to avoid a data outlier by specifying XLIM(1) = x-min, XLIM(2) = x-max and/or YLIM(1) = y-min, YLIM(2) = y-max. The user can impose limits in one ordinate while self-scaling in the other. The user can return to self-scaling by setting the limits back to zero between calls to PLOTIT.
User-scaling can be accomplished more simply by calling
call plotit_axes(xmin,xmax,ymin,ymax)
immediately before calling PLOTIT. As above, you can self-scale in
one
variable while imposing limits in the other by setting e.g.
xmin=xmax=0.
The user can return to self-scaling by setting the limits back to zero
between calls to PLOTIT.
EXAMPLES:
This code snippet will plot evenly-spaced data in array dat4 three
traces
at a time with solid lines.
The "x" spacing is specified in cc4, x0=cc4(1), dx=cc4(2)
The "nst" argument tells PLOTIT to plot
dat4(nst,.,.), dat4(nst1,.,.), dat4(nst+2,.,.),
... dat4(nst+npts-2,.,.), dat4(nst+npts-1,.,.).
The (k/3) in the IPNOW entry takes advantage of Fortran integer
arithmetic
to wit: 1/3=0; 2/3=0; and 3/3=1,
so the plot is generated after the third trace is entered.
title, xlabel and ylabel are character variables with the titles
...... do ity=1,3
........ do k=1,3
.......... call
plotit(cc4,dat4(nst,k,ity),dum,npts,title,xlabel2,
.... x ........ ylabel(ity),1,0,0,0,(k/3))
........ end do
...... end do
MANYPLOT is a driver for PLOTIT that arranges seismic traces one-above-the-other for easy viewing. It can be accessed by loading plotlib.a, just as one loads PLOTIT.
...... subroutine
manyplot(n,n1,np,nplot,b,a,shrink,title,xlab,ylab)
c to space traces, and plot no more than 1500
points
c n - inner dimension of input array
c n1 - first point to plot
c np - # of points to plot in each trace
c nplot - # of traces
c b - array with x0,dx
c a - array with traces to plot
c shrink - =1.0 means no overlap >1.0 implies
extra spacing, <1.0 condenses
c title,xlab,ylab - plot labels
...... character*(*) title,xlab,ylab
......
common/manyp/pstart,pmin(20),pmax(20),pzero(20),p(900)
...... dimension a(n,nplot),b(1),bb(3)
The title and axis labels can be written in four different fonts: simplex, duplex, complex (default), and italic. Font changes are accomplished with the first three letters of the font enclosed in backslashes. One can change fonts within an input character string like so:
IITIT = 'My best and \ita\only \com\plot'
The word 'only' will appear italicized, the rest will appear in complex font. PLOTIT will take the title font as the default for the rest of the lettering on the graph unless explicitly changed e.g. if IITIT='\dup\', no title is written but, in the absence of other font changes, all lettering will use duplex font. Greek letters are obtained by enclosing the name of the letter in backslashes e.g. \omega\. Capital Greek letters are obtained by typing the name in caps: e.g. \OMEGA\. Subscripts and superscripts are plotted with the constructions '\sub{..}' and `\sup{...}' e.g. x\sup{2} is x-squared. Many symbols are written by enclosing a numerical code in backslashes. \N\ where N=1999+ISYMBL will write one of the plotting symbols into a label.
Other available symbols are:
| N
1387 curly d 1388 del operator 1389 member of 1390 less than or equal to 1391 greater than or equal to 1392 proportional 1393 integral 1394 circuit integral 1395 infinity 1396 + or - 1397 - or + 1398 multiplication sign 1399 division sign 1400 product sign 1401 times dot 1402 radical sign |
N
1403 summation 1404 regular theta 1405 { 1406 } 1407 @ 1408 hat 1409 { 1410 } 1411 # 1412 paragraph symbol 1413 dagger 1425 tall < 1426 tall > 1429 degree 1430 tends to 1431 regular phi |
PLOTIT runs interactively, that is, it interrogates the user for one or two plotting options before plotting the data. Most options are imbedded in the first question, in which PLOTIT asks for a plotting option number ICK.
If ICK = 0, no plot is generated, the data buffers are flushed, and control is returned to the routine that called PLOTIT
If ICK = 3, the routine will open an X window and plot the graph in it.
If ICK = 4, the routine will open an X window and plot the graph in it. It will also write the plot to a file in postscript. It will prompt you for a filename after you have clicked the graph to return control to the main program.
If ICK < 0, the routine will plot according to the absolute value of ICK but also will write a textronix plot file to disk. If this option is chosen, the routine will ask for a filename. DO NOT enter a filename with a suffix!. PLOTIT will append the suffix (.TXP) automatically to the file
If you are like me, typing all the f77 parameters is dogswork. I recommend adding these lines to your .cshrc file, if it is not there already:
alias xf77 'f77 -I/usr/X11R6/include
-L/usr/X11R6/lib
-lX11 '
alias xcc 'cc -I/usr/X11R6/include
-L/usr/X11R6/lib
-lX11 '
The executable image of your program will be somewhat larger, as the object file for PLOTIT contains instructions on drawing letters and symbols for all four fonts. EXOTIC PROBLEMS CAN OCCUR if the common block of your program accidentally match those of PLOTIT, or if an array-out-of-bounds error (often not detected in Fortran compilation) happens to wipe out some of PLOTIT's default parameters - both of these snafus have happened to me.
PLOTIT can write crude postscript versions of its files. "Crude" means that PLOTIT was originally written for a penplotter, so all commands involve moving the cursor, even when drawing letters. The postscript output files contain instructions on how you can change the postscript afterwards to add lettering and replace titles and labels with more compact postscript commands. Since each string of penplotter commands has a comment to indicate its starting point, a creative programmer can postprocess the files to add color selectively.
Good Hunting, Jeffrey Park 5/14/2003