How To Use Files

XYPLOT offers a unique graphical environment for working with sets of (x, y) data. The XYPLOT workspace treats each set as a single entity. You may think in terms of operations on sets, rather than on individual numbers. This structure allows you to use fast simple procedures to perform powerful operations. Sets of data and their visual representations constitute the workspace.

The Windows and Linux versions of xyplot can accomodate arbitrarily large datasets, while the DOS version can hold up to 16,000 (x,y) pairs, partitioned into a maximum of 10 datasets. XYPLOT may read a file on disk and place the information in a dataset, or it may create a file and save the contents of a dataset on disk. The DOS version also reads and writes files that contain its entire workspace. The chapter describes the program's use of these files.

The Structure of Data Files

XYPLOT reads data from and stores data to plain text files. These are the files that appear sensibly displayed on the screen when you type

type filename.dat

or, under Linux,

cat filename.dat

for example. To be more precise, they are known as ASCII files, which stands for the widely adopted American Standard Code for Information Interchange. Information saved in files of this sort may be read by almost any computer.

Data files contain numbers arrayed in one or more columns preceeded by an optional header.

  1. A single column of data represents the y values with x, understood, a running index from one to the number of points.

  2. A two column file represents (x, y) pairs. The first column is x.

  3. With files of three or more columns, you are prompted to specify from the keyboard which column represents x and which column represents y.
Many mathematical operations require that the values of x are either in ascending or descending order in that file.

If lines of text are included at the beginning of the file and enclosed between the /* and */ symbols, XYPLOT interprets the information as a descriptive header. For example, the data might be measurements of thermocouple voltages at different times. The header could be used to save whatever information you want to record about how the measurements were made. When you apply a calibration to convert the voltages to temperatures, a record of the calibration will be inserted automatically into the header. You may save the calibrated measurements in a new file together with the modified header.

The example below illustrates a data file with two columns. Use your favorite text editor to create this or other data files or write them with other programs. A valid data file has the following characteristics:

[Beginning of file]
Test data to illustrate file format.

-3.0 9.0
-2.0 4.0
-1.0 1.0
0.0 0.0
1.0 1.0
2.0 2.0
3.0 9.0
[End of file]

In the example above the numbers are in floating point format, and the column delimiter is a single space.

Under Windows and Linux: An alternative style of header may be used in which each header text line is preceeded by the # character. This style is useful for its compatibility with other graphing programs such as Grace. Also, users may write Forth modules for loading their own custom format data files, such as binary data files, into xyplot.