![]() |
Previous | Table Of Contents | Next | ![]() |
File Operations
Now that we have manually entered a few data sets we would probably like to save this data into a plain-text (i.e. ASCII) data file. Such data files employ the .TXT filename suffix and are the only type of file which you can view using the Notepad word processor that Microsoft includes with every version of their operating system.
To save your data to a data file select either "Save" or "Save As" from the File menu on the main menu bar. If you have never assigned a filename to this data then you will next be greeted with the standard Windows Save As filename dialog which asks you to specify a filename. You can also use this dialog to navigate to wherever in the Windows file system you wish to place the file. Assuming the particular case of the three data sets that we constructed in the prior help page, when you click on "Save" to close the standard Save (or Save As) dialog you will be greeted with the following message:
This dialog is telling us that we were only able to save the first data set in the data file (for which we chose the filename "junk.txt"). The problem is that the three data sets do not have compatible x axis values, which is a requirement for multiple data sets to share a single cGraph data file. The reason for this will become clear shortly. If the three data sets had shared the same x axis values then they would have all been saved to the data file we just created.
Let's take a look at the contents of a cGraph data file. Just as there are two menu options labeled "Manually enter y data..." and "Manually enter x,y data..." there are two flavors of cGraph data file called an implicit x and an explicit x data file. The File/Save (and File/Save As) menu choice creates the type of file that corresponds to the first data set. For the particular case of the three data sets that we constructed in the prior help page, the first data set was an implicit x data set since it originated with the "Manually enter y data..." menu choice. Hence the File/Save As operation created the implicit x data file which is shown below. Remember that you can use Notepad to show you the contents of these data files.
The first line of the data file states that it is an implicit X data file. This means that every data point is specified only by its y axis value and the x axis value is understood. You can see the four y axis data points at the bottom of the data file. The next three lines hold the title, horizontal axis label, and the set label seen in the legend for this data set.
You are free to create implicit x and explicit x data files using Notepad (or any other word processor as long as you specify a "plain text" file). The ImplicitX, ExplicitX, Title, HorzAxisLabel, and SetLabels statements are all optional. When a file lacks either the ImplicitX or ExplicitX declaration statement it is treated by cGraph as an implicit x data file. An example of an explicit X data file is shown below. This example also shows that data files can contain blank lines and comment lines.
In an explicit x data file, every data point must be described by an (x,y) pair. But this example explicit x data file has 3 columns of numbers. What gives? If you ask cGraph to read this last data file (via the File/Open menu choice) you will get the following plot.
As you can see, the 3 columns of numbers have been interpreted by cGraph as shown below:
Hence this file holds two data sets. The first data set consists of the points (x1, y1_1), (x2, y1_2), ... The second data set consists of the points (x1, y2_1), (x2, y2_2), ... An explicit x data file can contain any number of columns as long as that number is at least 2. An implicit x data file can contain any number of columns as long as that number is at least 1. In either case, all the data sets share the same x axis values.
Even though a cGraph data file cannot hold incompatible data sets, the cGraph window does not mind overlaying data sets with incompatible x axis values. Incidentally, if you really need to save an incompatible second data set to a cGraph data file you can accomplish this -- after saving the first data set -- by deleting the first data set via the "Edit/Delete Line..." menu choice. This action promotes the second data set to the first data set which is the one that gets to call the shots as far as who else gets to share its data file. Then perform the File/Save As operation (if you choose File/Save you will overwrite the prior first data set).
On the File menu you will notice the two choices File/Open and File/Append. The difference between these is that the former clears any prior graph and the latter simply adds to it.
![]() |
Previous | Table Of Contents | Next | ![]() |