conplot
A contour plotting program written in perl. Version 1.30 is new on July 7, 2000 (has slight changes in setting the paths, and the optional use of a conplot_desc directory)

Last modified Friday, 26-Mar-2004 22:12:48 PST
return to mensch.org

Example of conplot showing off its abilities with color-fills, stretched grids, and vector fields.


conplot is a contour plotting program written in perl. I wrote conplot because my other program, d2ps, is not robust (it frequently crashes) and the output files are rather big. conplot also has its defects, one being that it is very slow. conplot can use data files in the gnuplot format. (The older version of conplot did not have this property and has been abandoned.)

Installing conplot

  1. Make a directory conplot, (type mkdir conplot).

  2. Download the following four files into conplot:

  3. Edit the first line of conplot, clegend and cpalt to be the correct path to perl, if need be. (Usually either /usr/bin/perl or /usr/local/bin/perl).

  4. Exit the editor and type chmod u+x conplot clegend cpalt

  5. In your home directory, edit your .cshrc file to contain the following line at the end of the file:
    set path=($path ~/conplot)
    
    That statement adds the directory conplot to your path. You will be able to use executable programs in conplot from any directory, the way you use gnuplot, for example.

  6. Exit the editor and type source .cshrc

  7. In your home directory type mkdir conplot_ex

  8. Download into conplot_ex:

  9. In conplot_ex, type:
    makedata
    
    A file squash.dat should have appeared in your directory. Now make a plot with:
    conplot squash.dat -k squash.desc squash.eps
    
    You can make a color legend with:
    clegend  squash.eps %4.2f
    ghostview squash_clegend.eps 
    
  10. The -k option uses the squash.desc to define the plotting parameters. Simply typing conplot squash.dat will also make a plot temp.eps using the parameters default.desc in the conplot directory.

  11. You can make a universally accessible directory for your description files, accessed wtih -dk rather than -k. See the third line of conplot to name the directory.

  12. The statement:
    conplot squash.dat -k squash.desc squash.eps -b
    
    is a "batch" job the bypasses the display to the monitor.

  13. makedata has made a data file with the format
    x1, y1, z(x1,y1), u(x1,y1), v(x1,y1)
    x2, y1, z(x2,y1), u(x2,y1), v(x2,y1)
    x3, y1, z(x3,y1), u(x3,y1), v(x3,y1)
    x4, y1, z(x4,y1), u(x4,y1), v(x4,y1)
    ...
    blank line
    x1, y2, z(x1,y2), u(x1,y2), v(x1,y2)
    x2, y2, z(x2,y2), u(x2,y2), v(x2,y2)
    x3, y2, z(x3,y2), u(x3,y2), v(x3,y2)
    x4, y2, z(x4,y2), u(x4,y2), v(x4,y2)
    ...
    
    The format is compatible with gnuplot. See below.

  14. Both the .dat file and .desc file may include perl statements that conplot recognizes and executes to define plotting parameters. (There is a gaping security hole here. Know who your friends are before you plot data files they have given you.) Edit squash.dat to contain the following two lines at the beginning:
    #$in=17;$jn=17;
    #$title='alternative';
    
    Also, you may delete some, or all, of the blank lines in squash.dat. The array dimensions are determined by the values of $in and $jn. $in defines the number of points in the x-direction and $jn defines the number of points in the y-direction. (Deleting these blank lines makes squash.dat no longer compatible with gnuplot). Again try:
    conplot squash.dat -k squash.desc squash.eps
    

  15. For color choices, look near the end of the conplot source code. Choices are: Using $colortable="default" makes a pretty nice plot when you have positive and negative data and you set $smin=-$smax.

  16. The .eps files are interesting to read, especially after your have read the PostScript Tutorial. Many features of plots in the .eps files produced by conplot can be easily turned on or off by uncommenting certain lines in the header of the .eps file. Also colors, labels and fonts can be changed with simple editing of the .eps file, long after you have lost the original data. This feature is one of the main benefits of using conplot, instead of ncargraphics.

    The perl script cpalt can do the editing for you. Try:

    cpalt squash.eps nogrid noregions noarrows contours
    
    You should see:

    Restore it with:
    cpalt squash.eps grid regions arrows nocontours
    

  17. conplot also stores alot of information as comments at the end of the .eps file. The comments found in the data file and description file are also reproduced there.

  18. Contour labels can be put on manually. To see some samples, "uncomment" the last four lines of squash.eps (before the blank line seperating the information comments), to read:
    /Helvetica 12 selectfont
    %uncomment next four lines for example labels
    105 105 BX
    (this) show
    305 205 BX
    (that) show
    
    The numbers define the position of the lower left corner of the labels. These positions can be obtained by displaying the .eps with ghostview squash.eps and then pointing the cursor where you want the label. The ghostview window has a small box that displays the current coordinates of the cursor. You can write down those numbers, and then make label commands with a text editor.

  19. You can convert the .eps files to a .gif with:
    convert +dither squash.eps squash.gif
    
    or, using the latest version of convert with Linux 6.1;
    convert +antialias squash.eps squash.gif
    
    If all goes well, squash.gif will be 23K. If it comes out to be about 205K, then blame the lawyers of Unisys.

    Also, be sure to use the +dither or +antialias option. The command:

    convert squash.eps squash.gif
    
    will use the -dither (-antialias) as the default, and produce:

    If you look closely, you can see the triangles that are part of the contouring algorithm, which is probably undesirable.


conplot can overlay dots

First download mydots, which contains lines with x y dot_index triplets. The dot_index can range from 1 to 8. Try:

conplot squash.dat -k squash.desc squash.eps -dots mydots

Near the end of squash.eps you will find %start_dots with definitions for Dot1, Dot2, etc. You can easily change the color, size and shape of these with a litte editing. (cpalt does not yet work with dots.)

conplot can make pixel plots

Try:

conplot squash.dat -px

or

conplot squash.dat -pxx

The -pxx uses exactly one pixel per data point, and was used to make the images seen here . The -px option uses more than one pixel per data point, and scales the plot to look nice. Both of these options are much faster than making contours.


Still more feautures

The gnuplot alternative

conplot does things that gnuplot does not: filling contours, plotting vector fields and pixel plots.

gnuplot does things that conplot does not: rendering surfaces.

conplot has been designed so that it can plot data files in the gnuplot format.
The file squash.dat made by makedata is such an example. Let's see what gnuplot can do with the first three columns of the file. First type gnuplot to bring up the gnuplot> command line. Then:

gnuplot> set parametric
gnuplot> set cntrparam levels incremental -.95,.1,.95
gnuplot> set contour base
gnuplot> splot 'squash.dat' with lines
gnuplot> set view 0,0,1
gnuplot> replot
gnuplot> set nosurface
gnuplot> replot

You should see plots like: