home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff391.lzh / ListPlot / Csrc / ListPlot.c < prev    next >
C/C++ Source or Header  |  1990-10-27  |  20KB  |  719 lines

  1. /*
  2.  * ListPlot.c
  3.  *
  4.  * Yet another plotting filter.
  5.  *
  6.  */
  7. #include <stdio.h>
  8. #include <errno.h>
  9. extern int errno;
  10. #include <assert.h>
  11. #include <string.h>
  12. #include <ctype.h>
  13. #include <signal.h>
  14. #include "datatypes.h"
  15.  
  16. void    ErrorExit();
  17. char    *calloc();
  18.  
  19. /* initializations    */
  20. char    *Usage[] = {
  21.     "Usage: ListPlot [Options]\n",
  22.     0
  23. };
  24. char    *Function[] = {
  25.     "Function: Yet another plotting filter. For help, enter \"ListPlot help\".\n\tFor more verbose help, enter \"ListPlot Verbose=on help=all\".\n",
  26.     "\n",
  27.     "\tListPlot supports a number of different devices.\n",
  28.     "\n",
  29.     "\tListPlot reads from stdin and writes to stdout unless input and/or\n",
  30.     "\toutput files are specified on the command line.\n",
  31.     "\tThe program accepts a file of n-tuples.  Each tuple consists of\n",
  32.     "\ta sequence of space separated numbers terminated with a newline.\n",
  33.     "\tThe first element of each tuple is assumed to be the independent\n",
  34.     "\tvariable.  Each remaining element is plotted against the first to\n",
  35.     "\tproduce n-1 curves.\n",
  36.     "\n",
  37.     "\tListPlot takes a number of command line arguments that may be\n",
  38.     "\tused to control the appearance of the plots.\n",
  39.     "\tFor a list of the arguments enter:\n",
  40.     "\t\tListPlot Help=All.\n",
  41.     "\n",
  42.     "\t'Boolean' values accept values such as true, false,\n",
  43.     "\tyes, no, on, and off. (ex. PlotColor=yes)\n",
  44.     "\n",
  45.     "\t'String' values expect the strings to entered as\n",
  46.     "\tindicated and is case sensitive. (ex. Domain=All)\n",
  47.     "\n",
  48.     "\t'Dbl' values expect real numbers. (ex. AspectRatio=1.0)\n",
  49.     "\n",
  50.     "\t'Interval' values expect a pair of comma separated reals.\n",
  51.     "\t\t(ex. Range=-1.0,3.0)\n",
  52.     "\n",
  53.     "\t'Set' values expect a list of comma separated elements enclosed in\n",
  54.     "\tcurly braces ({}). (ex. LineStyle={MS,MMS,MSmmS})\n",
  55.     "\n",
  56.     "\tThe title and label variables accept strings that include\n",
  57.     "\tthe following control sequences:\n",
  58.     "\t\t#u: move up to superscript position (ended with #d)\n",
  59.     "\t\t#d: move down to subscript position (ended with #u)\n",
  60.     "\t\t#b: backspace to allow overprinting\n",
  61.     "\t\t##: the number symbol\n",
  62.     "\t\t#+: toggle overline mode\n",
  63.     "\t\t#-: toggle underline mode\n",
  64.     "\t\t#gx: Greek letter corresponding to Roman letter x\n",
  65.     "\n",
  66.     0
  67. };
  68.  
  69. bool    GraphicsInProgress = FALSE;
  70.  
  71.  
  72. /* argument definitions    */
  73. /* GoldenRatio = (1+Sqrt(5))/2    */
  74. #define    GOLDENRATIO    1.6180339887499
  75. #define ASPECTRATIO    1.0/GOLDENRATIO
  76. char    *H_AngularUnit[] = {
  77.     "\t'AngularUnit' specifies the angular unit of measure\n",
  78.     "\tused for polar plots.  For angles in radians use\n",
  79.     "\t\tAngularUnit=radians\n",
  80.     (char *)NULL
  81. };
  82. VALUE    V_AngularUnit;
  83. ARGDEF    A_AngularUnit = {
  84.         &V_AngularUnit,            /* variable    */
  85.         "AngularUnit",            /* ID        */
  86.         "degrees|radians",        /* options    */
  87.         "string|string",        /* format    */
  88.         "degrees",            /* default    */
  89.         "string",            /* Default type */
  90.         H_AngularUnit
  91.     };
  92. char    *H_AnnotationScale[] = {
  93.     "\t'AnnotationScale' controls the size of the characters\n",
  94.     "\tused to annotate the axises.\n",
  95.     (char *)NULL
  96. };
  97. VALUE    V_AnnotationScale;
  98. ARGDEF    A_AnnotationScale = {
  99.         &V_AnnotationScale,        /* variable    */
  100.         "AnnotationScale",        /* ID        */
  101.         "dbl",                /* options    */
  102.         "dbl",                /* format    */
  103.         "0.50",                /* default    */
  104.         "dbl",                /* Default type */
  105.         H_AnnotationScale
  106.     };
  107. char    *H_AspectRatio[] = {
  108.     "\t'AspectRatio' controls the relative lengths of the vertical to\n",
  109.     "\thorizontal axes.  The default is 1.0/GoldenRatio.\n",
  110.     "\t\tAspectRatio=0.618\n",
  111.     "\tIf set this value overrides the value of 'ViewPort'.\n",
  112.     (char *)NULL
  113. };
  114. VALUE    V_AspectRatio;
  115. ARGDEF    A_AspectRatio = {
  116.         &V_AspectRatio,            /* variable    */
  117.         "AspectRatio",            /* ID        */
  118.         "dbl|Automatic",        /* options    */
  119.         "dbl|string",            /* format    */
  120.         "0.61803399",            /* default    */
  121.         "dbl",                /* Default type */
  122.         H_AspectRatio
  123.     };
  124. char    *H_Boxed[] = {
  125.     "\t'Boxed' adds axes to the edges of the plot.\n",
  126.     "\tIf 'Boxed is given a boolean value then axes are placed on\n",
  127.     "\tall of the edges.  If 'Boxed' is given a string consisting\n",
  128.     "\tof one or more of 't','b','r','l' then axes are added to\n",
  129.     "\ttop, bottom, right and left edges respectively.\n",
  130.     (char *)NULL
  131. };
  132. VALUE    V_Boxed;
  133. ARGDEF    A_Boxed = {
  134.         &V_Boxed,            /* variable    */
  135.         "Boxed",            /* ID        */
  136.         "boolean|*",            /* options    */
  137.         "boolean|string",            /* format    */
  138.         "yes",                /* default    */
  139.         "boolean",            /* Default type */
  140.         H_Boxed
  141.     };
  142. char    *H_Domain[] = {
  143.     "\t'Domain' may be used to specify the bounds on the X axis.\n",
  144.     (char *)NULL
  145. };
  146. VALUE    V_Domain;
  147. ARGDEF    A_Domain = {
  148.         &V_Domain,                /* variable    */
  149.         "Domain",                /* ID        */
  150.         "interval|All|Automatic",        /* options    */
  151.         "interval|string|string",        /* format    */
  152.         "All",                    /* default    */
  153.         "string",                /* Default type */
  154.         H_Domain
  155.     };
  156. char    *H_Gridding[] = {
  157.     "\t'Gridding' puts a grid on the plot.\n",
  158.     (char *)NULL
  159. };
  160. VALUE    V_Gridding;
  161. ARGDEF    A_Gridding = {
  162.         &V_Gridding,            /* variable    */
  163.         "Gridding",            /* ID        */
  164.         "boolean",            /* options    */
  165.         "boolean",            /* format    */
  166.         "no",                /* default    */
  167.         "boolean",            /* Default type */
  168.         H_Gridding
  169.     };
  170.  
  171. /* N.B. Help is treated differently than other variables and its
  172.  * arguments should only be of type "string"!
  173.  */
  174. char    *H_Help[] = {
  175.     "\t'Help' provides some descriptive text for the user-settable\n",
  176.     "\tplotting variables.  If the variable 'Verbose' is set then\n",
  177.     "\tan extended description is provided. To set verbose enter\n",
  178.     "\t\tListPlot Verbose=yes Help=[variable name | All].\n",
  179.     (char *)NULL
  180. };
  181. VALUE    V_Help;
  182. ARGDEF    A_Help = {
  183.         &V_Help,            /* variable    */
  184.         "Help",                /* ID        */
  185.         "All|all|*",            /* options    */
  186.         "string|string|string",        /* format    */
  187.         "All",                /* default    */
  188.         "string",            /* Default type */
  189.         H_Help
  190.     };
  191. char    *H_LabelScale[] = {
  192.     "\t'LabelScale' specifies the relative size of the vertical and\n",
  193.     "\thorizontal axis labels.  The typical range is [0.5 - 2.0].\n",
  194.     (char *)NULL
  195. };
  196. VALUE    V_LabelScale;
  197. ARGDEF    A_LabelScale = {
  198.         &V_LabelScale,            /* variable    */
  199.         "LabelScale",            /* ID        */
  200.         "dbl",                /* options    */
  201.         "dbl",                /* format    */
  202.         "0.85",                /* default*/
  203.         "dbl",                /* Default type */
  204.         H_LabelScale
  205.     };
  206. char    *H_LineColor[] = {
  207.     "\t'LineColor' may be used to specify a list of line colors for\n",
  208.     "\tplots with multiple curves if this feature is supported for\n",
  209.     "\ta particular output device.\n",
  210.     (char *)NULL
  211. };
  212. VALUE    V_LineColor;
  213. ARGDEF    A_LineColor = {
  214.         &V_LineColor,            /* variable    */
  215.         "LineColor",            /* ID        */
  216.         "set",                /* options    */
  217.         "set",                /* format    */
  218.         "{Black,Red,Green,Blue,Yellow}",    /* default*/
  219.         "set",                /* Default type */
  220.         H_LineColor
  221.     };
  222. char    *H_LineStyle[] = {
  223.     "\t'LineStyle' may be used to specify a list of line styles for\n",
  224.     "\tplots with multiple curves.  Each linestyle is specified as\n",
  225.     "\ta sequence of pen down... pen up elements. The elements are encoded\n",
  226.     "\tusing the following characters to indicate element lengths:\n",
  227.     "\t\t'm':\t250 micron mark\n",
  228.     "\t\t'M':\t4 m's or a 1mm mark\n",
  229.     "\t\t's':\t250 micron space\n",
  230.     "\t\t'S':\t4 s's or a 1mm space\n",
  231.     "\n",
  232.     "\tFor example, a set of line styles might be indicated\n",
  233.     "\t\tLineStyle={MS,MMSS,MMSmmS,mmS,mmSmmSMMS}\n",
  234.     (char *)NULL
  235. };
  236. VALUE    V_LineStyle;
  237. ARGDEF    A_LineStyle = {
  238.         &V_LineStyle,            /* variable    */
  239.         "LineStyle",            /* ID        */
  240.         "set",                /* options    */
  241.         "set",                /* format    */
  242.         "{MS,MMSS,MMSmmS,mmS,mmSmmSMMS}",/*default*/
  243.         "set",                /* Default type */
  244.         H_LineStyle
  245.     };
  246. char    *H_Origin[] = {
  247.     "\tThe 'Origin' option is not yet implemented. It is intended\n",
  248.     "\tthat this feature beused to specify the origin of the plot.\n",
  249.     (char *)NULL
  250. };
  251. VALUE    V_Origin;
  252. ARGDEF    A_Origin = {
  253.         &V_Origin,            /* variable    */
  254.         "Origin",            /* ID        */
  255.         "interval|Automatic|Median",    /* options    */
  256.         "interval|string|string",    /* format    */
  257.         "Automatic",            /* default    */
  258.         "string",            /* Default type */
  259.         H_Origin
  260.     };
  261. char    *H_PlotColor[] = {
  262.     "\t'PlotColor' if TRUE causes the plot to generated in color if this\n",
  263.     "\tfeature is supported on a particular output device.\n",
  264.     (char *)NULL
  265. };
  266. VALUE    V_PlotColor;
  267. ARGDEF    A_PlotColor = {
  268.         &V_PlotColor,            /* variable    */
  269.         "PlotColor",            /* ID        */
  270.         "boolean",            /* options    */
  271.         "boolean",            /* format    */
  272.         "no",                /* default    */
  273.         "boolean",            /* Default type */
  274.         H_PlotColor
  275.     };
  276. char    *H_PlotDevice[] = {
  277.     "\t'PlotDevice' specifies output device type.\n",
  278.     (char *)NULL
  279. };
  280. VALUE    V_PlotDevice;
  281. ARGDEF    A_PlotDevice = {
  282.         &V_PlotDevice,            /* variable    */
  283.         "PlotDevice",            /* ID        */
  284.         "amiga|printer|iff|hp|aegis|postscript",/* options    */
  285.         "string|string|string|string|string|string",/* format    */
  286.         "amiga",            /* default    */
  287.         "string",            /* Default type */
  288.         H_PlotDevice
  289.     };
  290. char    *H_PlotJoined[] = {
  291.     "\t'PlotJoined' is set connects each data point with a line in the\n",
  292.     "\tcurrent line style. (ex PlotJoined=on )\n",
  293.     (char *)NULL
  294. };
  295. VALUE    V_PlotJoined;
  296. ARGDEF    A_PlotJoined = {
  297.         &V_PlotJoined,            /* variable    */
  298.         "PlotJoined",            /* ID        */
  299.         "boolean",            /* options    */
  300.         "boolean",            /* format    */
  301.         "yes",                /* default    */
  302.         "boolean",            /* Default type */
  303.         H_PlotJoined
  304.     };
  305. char    *H_PlotPoints[] = {
  306.     "\t'PlotPoints' if set causes symbols to be plotted in the current\n",
  307.     "\tsymbol style at each data point. (ex. PlotPoints=true )\n",
  308.     (char *)NULL
  309. };
  310. VALUE    V_PlotPoints;
  311. ARGDEF    A_PlotPoints = {
  312.         &V_PlotPoints,            /* variable    */
  313.         "PlotPoints",            /* ID        */
  314.         "boolean",            /* options    */
  315.         "boolean",            /* format    */
  316.         "false",            /* default    */
  317.         "boolean",            /* Default type */
  318.         H_PlotPoints
  319.     };
  320. char    *H_PlotTitle[] = {
  321.     "\t'PlotTitle' takes the plot title as an argument.\n",
  322.     "\tGreek symbols may be specified by preceding a character by\n",
  323.     "\t'#g'. Superscripts and subscripts may be specified using\n",
  324.     "\t'#u', '#d' respectively.\n",
  325.     (char *)NULL
  326. };
  327. VALUE    V_PlotTitle;
  328. ARGDEF    A_PlotTitle = {
  329.         &V_PlotTitle,            /* variable    */
  330.         "PlotTitle",            /* ID        */
  331.         "*",                /* options    */
  332.         "string",            /* format    */
  333.         "",                /* default    */
  334.         "string",            /* Default type */
  335.         H_PlotTitle
  336.     };
  337. char    *H_PlotType[] = {
  338.     "\t'PlotType' specifies the 'graph paper' upon which the plot is drawn.\n",
  339.     "\tThe current implementation plots in\n",
  340.     "\t\tlinear-linear,\n",
  341.     "\t\tlog-linear,\n",
  342.     "\t\tlinear-log,\n",
  343.     "\t\tlog-log, and\n",
  344.     "\t\tpolar\n",
  345.     "\tformats.\n",
  346.     "\tFor the log type plots, the log of the data is computed\n",
  347.     "\tby ListPlot.\n",
  348.     "\tFor polar plots, see also 'AngularUnit' and 'PolarVariable'.\n",
  349.     (char *)NULL
  350. };
  351. VALUE    V_PlotType;
  352. ARGDEF    A_PlotType = {
  353.         &V_PlotType,            /* variable    */
  354.         "PlotType",            /* ID        */
  355.         "linlin|loglin|linlog|loglog|polar",/* options    */
  356.         "string|string|string|string|string",/* format    */
  357.         "linlin",            /* default    */
  358.         "string",            /* Default type */
  359.         H_PlotType
  360.     };
  361. char    *H_PointScale[] = {
  362.     "\t'PointScale' controls the relative size of the data point symbols\n",
  363.     "\twhen data point symbols are being plotted.\n",
  364.     (char *)NULL
  365. };
  366. VALUE    V_PointScale;
  367. ARGDEF    A_PointScale = {
  368.         &V_PointScale,            /* variable    */
  369.         "PointScale",            /* ID        */
  370.         "dbl",                /* options    */
  371.         "dbl",                /* format    */
  372.         "1.0",                /* default    */
  373.         "dbl",                /* Default type */
  374.         H_PointScale
  375.     };
  376. char    *H_PointSymbol[] = {
  377.     "\t'PointSymbol' specifies a list of symbols to be used when plotting\n",
  378.     "\tdata points. The symbols types are encoded as integers.\n",
  379.     "\tSee the PLPLOT library documentation to find the symbols\n",
  380.     "\tavailable.\n",
  381.     (char *)NULL
  382. };
  383. VALUE    V_PointSymbol;
  384. ARGDEF    A_PointSymbol = {
  385.         &V_PointSymbol,            /* variable    */
  386.         "PointSymbol",            /* ID        */
  387.         "Automatic|set",        /* options    */
  388.         "string|set",            /* format    */
  389.         "Automatic",            /* default    */
  390.         "string",            /* Default type */
  391.         H_PointSymbol
  392.     };
  393. char    *H_PolarVariable[] = {
  394.     "\t'PolarVariable' for polar plots is used to specify\n",
  395.     "\twhether the independent variable is angular or radial.\n",
  396.     (char *)NULL
  397. };
  398. VALUE    V_PolarVariable;
  399. ARGDEF    A_PolarVariable = {
  400.         &V_PolarVariable,        /* variable    */
  401.         "PolarVariable",        /* ID        */
  402.         "angle|radius",            /* options    */
  403.         "string|string",        /* format    */
  404.         "angle",            /* default    */
  405.         "string",            /* Default type */
  406.         H_PolarVariable
  407.     };
  408. char    *H_Orientation[] = {
  409.     "\t'Orientation' controls whether the plot is displayed in\n",
  410.     "\tlandscape or portrait orientation.\n",
  411.     (char *)NULL
  412. };
  413. VALUE    V_Orientation;
  414. ARGDEF    A_Orientation = {
  415.         &V_Orientation,                /* variable    */
  416.         "Orientation",                /* ID        */
  417.         "portrait|landscape",            /* options    */
  418.         "string|string",            /* format    */
  419.         "landscape",                /* default    */
  420.         "string",                /* Default type */
  421.         H_Orientation
  422.     };
  423. char    *H_Range[] = {
  424.     "\t'Range' specifies the y axis bounds. (ex. Range=-1,1 )\n",
  425.     (char *)NULL
  426. };
  427. VALUE    V_Range;
  428. ARGDEF    A_Range = {
  429.         &V_Range,                /* variable    */
  430.         "Range",                /* ID        */
  431.         "interval|All|Automatic",        /* options    */
  432.         "interval|string|string",        /* format    */
  433.         "All",                    /* default    */
  434.         "string",                /* Default type */
  435.         H_Range
  436.     };
  437. char    *H_SubPages[] = {
  438.     "\t'SubPages' specifies the number of plots on a pages.\n",
  439.     "\tThis is a vestige of PLPLOT and I am not sure this has any use\n",
  440.     "\twithin the context of 'ListPlot.  It might be useful for\n",
  441.     "\tcontrolling the size of the plots but the 'ViewPort' might be\n",
  442.     "\ta more direct solution.\n",
  443.     (char *)NULL
  444. };
  445. VALUE    V_SubPages;
  446. ARGDEF    A_SubPages = {
  447.         &V_SubPages,                /* variable    */
  448.         "SubPages",                /* ID        */
  449.         "interval",                /* options    */
  450.         "interval",                /* format    */
  451.         "1.0,1.0",                /* default    */
  452.         "interval",                /* Default type */
  453.         H_SubPages
  454.     };
  455. char    *H_SupplyAbscissa[] = {
  456.     "\t'SupplyAbscissa' if set causes ListPlot to supply a value for\n",
  457.     "\tthe independent variable.\n",
  458.     (char *)NULL
  459. };
  460. VALUE    V_SupplyAbscissa;
  461. ARGDEF    A_SupplyAbscissa = {
  462.         &V_SupplyAbscissa,            /* variable    */
  463.         "SupplyAbscissa",            /* ID        */
  464.         "boolean",                /* options    */
  465.         "boolean",                /* format    */
  466.         "no",                    /* default    */
  467.         "boolean",                /* Default type */
  468.         H_SupplyAbscissa
  469.     };
  470. char     *H_TitleScale[] = {
  471.     "\t'TitleScale' controls the relative size of the title text.\n",
  472.     (char *)NULL
  473. };
  474. VALUE    V_TitleScale;
  475. ARGDEF    A_TitleScale = {
  476.         &V_TitleScale,                /* variable    */
  477.         "TitleScale",                /* ID        */
  478.         "dbl",                    /* options    */
  479.         "dbl",                    /* format    */
  480.         "1.0",                    /* default    */
  481.         "dbl",                    /* Default type */
  482.         H_TitleScale
  483.     };
  484. char    *H_UseInputFile[] = {
  485.     "\t'UseInputFile' permits the specification of an input file if\n",
  486.     "\tyou would rather not use stdin.\n",
  487.     (char *)NULL
  488. };
  489. VALUE    V_UseInputFile;
  490. ARGDEF    A_UseInputFile = {
  491.         &V_UseInputFile,        /* variable    */
  492.         "UseInputFile",            /* ID        */
  493.         "*",                /* options    */
  494.         "string",            /* format    */
  495.         "",                /* default    */
  496.         "string",            /* Default type */
  497.         H_UseInputFile
  498.     };
  499. char    *H_UseOutputFile[] = {
  500.     "\t'UseOutputFile' permits the specification of an output file if\n",
  501.     "\tyou would rather not use stdout.\n",
  502.     (char *)NULL
  503. };
  504. VALUE    V_UseOutputFile;
  505. ARGDEF    A_UseOutputFile = {
  506.         &V_UseOutputFile,        /* variable    */
  507.         "UseOutputFile",        /* ID        */
  508.         "*",                /* options    */
  509.         "string",            /* format    */
  510.         "",                /* default    */
  511.         "string",            /* Default type */
  512.         H_UseOutputFile
  513.     };
  514. /* Not used.  V_AspectRatio may be used to control viewport in a nicer way */
  515. char    *H_Verbose[] = {
  516.     "\t'Verbose' if set causes extended messaging.\n",
  517.     (char *)NULL
  518. };
  519. VALUE    V_Verbose;
  520. ARGDEF    A_Verbose = {
  521.         &V_Verbose,            /* variable    */
  522.         "Verbose",            /* ID        */
  523.         "boolean",            /* options    */
  524.         "boolean",            /* format    */
  525.         "off",                /* default    */
  526.         "boolean",            /* Default type */
  527.         H_Verbose
  528.     };
  529. char    *H_ViewPort[] = {
  530.     "\t'ViewPort' allows control over the size of a plot. Takes\n",
  531.     "\ta viewing rectangle diagonal as an argument.\n",
  532.     "\t\t(ex. ViewPort=\\{0.1,0.3, 0.9,0.6\\} )\n",
  533.     (char *)NULL
  534. };
  535. VALUE    V_ViewPort;
  536. ARGDEF    A_ViewPort = {
  537.         &V_ViewPort,            /* variable    */
  538.         "ViewPort",            /* ID        */
  539.         "rect",                /* options    */
  540.         "rect",                /* format    */
  541.         "{0.1,0.1,0.9,0.9}",        /* default    */
  542.         "rect",                /* Default type */
  543.         H_ViewPort
  544.     };
  545. char    *H_XLabel[] = {
  546.     "\t'XLabel' specifies X axis label.  Greek characters may be included\n",
  547.     "\tby preceding the character with '#g'.  Superscripts and subscripts\n",
  548.     "\tmay be included using '#u' and '#d' control sequences respectively.\n",
  549.     (char *)NULL
  550. };
  551. VALUE    V_XLabel;
  552. ARGDEF    A_XLabel = {
  553.         &V_XLabel,            /* variable    */
  554.         "XLabel",            /* ID        */
  555.         "*",                /* options    */
  556.         "string",            /* format    */
  557.         "",                /* default    */
  558.         "string",            /* Default type */
  559.         H_XLabel
  560.     };
  561. char    *H_XTick[] = {
  562.     "\t'XTick' controls the spacing of major axis ticks and the number\n",
  563.     "\tof minor subdivisions. (ex. XTick=0.1,10 indicates major ticks at\n",
  564.     "\tunits of 0.1 with 10 minor subdivisions.)\n",
  565.     (char *)NULL
  566. };
  567. VALUE    V_XTick;
  568. ARGDEF    A_XTick = {
  569.         &V_XTick,            /* variable    */
  570.         "XTick",            /* ID        */
  571.         "Automatic|interval",        /* options    */
  572.         "string|interval",        /* format    */
  573.         "Automatic",            /* default    */
  574.         "string",            /* Default type */
  575.         H_XTick
  576.     };
  577. char    *H_YLabel[] = {
  578.     "\t'YLabel' specifies Y axis label.  Greek characters may be included\n",
  579.     "\tby preceding the character with '#g'.  Superscripts and subscripts\n",
  580.     "\tmay be included using '#u' and '#d' control sequences respectively.\n",
  581.     (char *)NULL
  582. };
  583. VALUE    V_YLabel;
  584. ARGDEF    A_YLabel = {
  585.         &V_YLabel,            /* variable    */
  586.         "YLabel",            /* ID        */
  587.         "*",                /* options    */
  588.         "string",            /* format    */
  589.         "",                /* default    */
  590.         "string",            /* Default type */
  591.         H_YLabel
  592.     };
  593. char    *H_YTick[] = {
  594.     "\t'YTick' controls the spacing of major axis ticks and the number\n",
  595.     "\tof minor subdivisions. (ex. YTick=0.1,10 indicates major ticks at\n",
  596.     "\tunits of 0.1 with 10 minor subdivisions.)\n",
  597.     (char *)NULL
  598. };
  599. VALUE    V_YTick;
  600. ARGDEF    A_YTick = {
  601.         &V_YTick,            /* variable    */
  602.         "YTick",            /* ID        */
  603.         "Automatic|interval",        /* options    */
  604.         "string|interval",        /* format    */
  605.         "Automatic",            /* default    */
  606.         "string",            /* Default type */
  607.         H_YTick
  608.     };
  609.     
  610. ARGDEF    *SymbolTable[] = {
  611.         &A_AngularUnit,
  612.         &A_AnnotationScale,
  613.         &A_AspectRatio,
  614.         &A_Boxed,
  615.         &A_Domain,
  616.         &A_Gridding,
  617.         &A_Help,
  618.         &A_LabelScale,
  619.         &A_LineColor,
  620.         &A_LineStyle,
  621.         &A_Orientation,
  622.         &A_Origin,
  623.         &A_PlotColor,
  624.         &A_PlotJoined,
  625.         &A_PlotPoints,
  626.         &A_PointScale,
  627.         &A_PointSymbol,
  628.         &A_PlotTitle,
  629.         &A_PlotDevice,
  630.         &A_PlotType,
  631.         &A_PolarVariable,
  632.         &A_Range,
  633.         &A_SubPages,
  634.         &A_SupplyAbscissa,
  635.         &A_TitleScale,
  636.         &A_UseInputFile,
  637.         &A_UseOutputFile,
  638.         &A_Verbose,
  639.         &A_ViewPort,
  640.         &A_XLabel,
  641.         &A_YLabel,
  642.         &A_XTick,
  643.         &A_YTick,
  644.         (ARGDEF *)NULL
  645.     };
  646.  
  647. main(argc, argv)
  648. int    argc;
  649. char    **argv;
  650. {
  651.     register int    i;
  652.     int    NTuples, TupleSize;
  653.     FLOAT    **Data;
  654.     FILE    *Fp;
  655.     void    InterruptHandler();
  656. #ifdef    ANSI_C
  657.     FLOAT    **GetData(FILE *, int *, int *);
  658.     void    ListPlot(FLOAT **,int ,int );
  659. #else
  660.     FLOAT    **GetData();
  661.     void    ListPlot();
  662. #endif
  663.  
  664.  
  665.     get_args(argc, argv, SymbolTable, Usage, Function);
  666.  
  667.     if (VtoBoolean(V_Verbose)) {
  668.         fprintf(stderr, "Arg values:\n");
  669.         for (i=0; SymbolTable[i]; i++) {
  670.             fputc('\t' ,stderr);
  671.             PrintArg(stderr, SymbolTable[i]);
  672.         }
  673.     }
  674.  
  675.  
  676.     if (signal(SIGINT, SIG_IGN) != SIG_IGN)
  677.         signal(SIGINT, InterruptHandler);
  678.  
  679.  
  680.     if (strlen(V_UseInputFile.val_u.udt_string) > 0) {
  681.         if ((Fp = fopen(V_UseInputFile.val_u.udt_string, "r")) == (FILE *)NULL) {
  682.             perror(V_UseInputFile.val_u.udt_string);
  683.             exit(errno);
  684.         }
  685.     } else {
  686.         Fp = stdin;
  687.     }
  688.     if (strlen(V_UseOutputFile.val_u.udt_string) > 0) {
  689.         if (!freopen(V_UseOutputFile.val_u.udt_string, "w", stdout)) {
  690.             perror(V_UseOutputFile.val_u.udt_string);
  691.             exit(errno);
  692.         }
  693.     }
  694.     if ((Data = GetData(Fp, &NTuples, &TupleSize)) == (FLOAT **)NULL) {
  695.         /* error */
  696.         fprintf(stderr, "Unable to read data...\n");
  697.         ErrorExit();
  698.     }
  699.  
  700.     ListPlot(Data, NTuples, TupleSize);
  701. }
  702.  
  703.  
  704. void
  705. InterruptHandler()
  706. {
  707.     ErrorExit();    /* will not return        */
  708.     return;       /* To satisfy some compilers    */
  709. }
  710.  
  711.  
  712. void
  713. ErrorExit()
  714. {
  715.     if (GraphicsInProgress)
  716.         plend();
  717.     exit(0);
  718. }
  719.