Exporting Fit Curves and Resampling
Grapher 8 has the ability to add a fit curve to any line/scatter plot. This can be useful for displaying trends or for filling in gaps in data. Once the fit curve is displayed in the desired form, you can export the fit curve to a new data file. This data file can be imported into Didger, Golden Software's digitizing and georeferencing program, and resampled to any desired interval.
This article discusses creating a scatter plot, adding a fit curve, and exporting the fit curve data in Grapher. Also discussed is information about importing the file into Didger and resampling the curve to a specific interval. This data is then saved to a new DAT file for future use.
Creating a Scatter Plot
Line/scatter plots are created from two columns of data. The line that connects the points is plotted in the same order that the data appears in the worksheet. So, it is important to have the data sorted before creating the graph. The data set used for this newsletter can be downloaded from here. To create a line/scatter plot from this data, follow these steps:
- Choose Graph | 2D XY Graphs | Line/Scatter.
- Select the data file and click Open.
- To display only scattered points of the data with no line, choose Graph | Change Plot To | Scatter.
- If desired, click on the Symbol tab in the property inspector window to change the symbol to another shape. Click the + next to the Symbol command and select a new shape, such as a filled circle. The graph automatically updates.
A scatter plot displays the actual data values
of each point in the worksheet.
Adding a Fit Curve
To add a fit curve to the plot, click once on the scatter plot to select it. In the property inspector,
- Open the Plot tab.
- Next to the Fits command, click the <Click here to add/edit fits> text. The Fits dialog opens.
- Select the desired fit, such as a Spline smoothing fit and click the Add button.
- Multiple fit curves can be added by selecting another fit curve type, such as a Linear fit and clicking the Add button.
- Click the OK button. The graph is automatically updated to display the fit curves.
A scatter plot with two fit curves showing trends between the points.
Exporting the Fit Curve to a Data File
Once the fit curve is displayed on the graph, it can be selected and edited. For instance, if you click on the Line tab, you can change the Color. This is useful when you have multiple curves displayed. In this graph, there are three plots: a scatter plot, a spline smoothing fit curve, and a linear fit curve. A legend has been added to the graph using the Graph | Add to Graph | Legend command to distinguish each curve.
A legend easily determines which data each curve is displaying.
With the legend, we can easily see that the red curve is the spline smoothing curve while the blue curve is the linear fit curve. To export the spline smoothing fit curve data,
- Click on the red curve to select it.
Select the Spline smoothing
fit curve in the object manager.
- Choose the Graph | Export Plot Data command. A new worksheet opens.
Note the X values in column A. These values are not on an even interval. Instead, the numbers are spaced so that the fit curve is approximated in the data. By default, a fit curve has 200 points. Since this data was created from a default fit curve, it should have approximately 200 points.
- Scroll down to the last cell in the worksheet. You can quickly do this by pressing CTRL+END on the keyboard.
- Note the last row number that contains data.
Confirm the last row number with data.
- Scroll back to the top of the worksheet. You can quickly do this by pressing CTRL+HOME on the keyboard.
- In cell A1, type in the one less than the last row number. In this case, you can type in 200. This is the number of points that are in the file.
- In cell B1, type in the number 1. This is a flag for Didger when importing the file.
- Choose File | Save As. Type in a File name, such as fitdata. Change the Save as type to BLN Golden Software Blanking (*.bln). Click the Save button. The file is saved.
Importing and Altering the Fit Curve in Didger
Golden Software's Didger program allows manipulation of digitized data, as well as images, and data files. After opening Didger,
- Choose the File | Import command. Select the BLN file created in step 13 and click the Open button.
- In the Define Import Options dialog, ensure that Cartesian Coordinates is selected and click the OK button. The line appears.
Set the Coordinate Space Type to Cartesian Coordinates.
The line can be altered in many ways. One way to alter the line is to resample it. Resampling takes the original point values and alters them. This can be so that one value is evenly incremented or so that only a certain number of values are generated. In this example, we want to evenly increment the X values.
- Click on the line to select it.
- Choose the Tools | Resample Polyline command.
- In the Resample Polyline dialog, select Resample Along X Axis.
- Change the Increment Value to 1 so that a new point is generated at each integer X value.
- Uncheck the Create new line as only a single line is desired.
Resample the polyline to obtain evenly spaced data.
- Click the OK button. The curve is altered so that the data is only along the X values.
- Choose File | Export to create a new data file from the evenly spaced data. Type in a File name, such as exportedfitdata. Change the Save as type to DAT - Golden Software Data (*.dat). Click the Save button.
- In the Export Options dialog, select Separate objects with and type a comma in the box. Click the OK button to create the file.
Verifying the Data
In Grapher, you can choose the Graph | Add to Graph | Plot command to add a line/scatter plot to the existing graph. The new curve will overlay the fit curve almost exactly. If you open the data file, the X values are evenly spaced.
View the resampled data to ensure
it is evenly spaced, as desired.
- Didger 4: Projection and Datum Tips
- Next Article: Converting Post-processed MapViewer 7 Data to Display on Google Earth