Exercise Three: Graphing Data
This exercise uses the data generated in Exercise One and Exercise Two. If you have not completed these exercises STOP and complete the exercises. The model used in this exercise follows the data generating process below:
Step One: Load the saved x and y data
In the last part of this tutorial series, we saved two matrices x and y. You can load them by entering:
load x, y;
This command will look for the files x.fmt and y.fmt in your current working directory. It will then create matrices x and y in your GAUSS workspace and fill them with the data from the corresponding file.
Specifying a load path
If keep your data in a separate directory that you do not want to be your working directory, you can specify a separate ‘load’ path. When you specify a ‘load’ path, GAUSS will look in that directory when you load data with the load command.
load path = C:\gauss13\data; load x, y;
This code will attempt to load x and y from the directory C:\gauss13\data.
Step Two: Graph the data
Create a new file
Open a new program file by clicking the “New File” toolbar button, or using the hotkey CTRL+O.
Save the file
Save the file by either clicking the “Save File” toolbar button, or by using the hotkey CTRL+S. Give the file the name plotexample.gss.
Add commands to the program file
Add the load command from above. Next add the command:
to your file.
As you start typing plot… GAUSS will provide you with an auto fill menu listing all functions that begin with plot. You may use the arrow buttons to scroll to one of the functions in this dropdown list and hit enter to have GAUSS enter this command into your file.
You may also notice that when you type the opening parenthesis, GAUSS will give you a tooltip listing the inputs for the function.
Draw the graph
To run the file, either use the hotkey CTRL+R or select “Current File” from the dropdown menu next to the Run button.
After your file is run, you should see a graph that is similar to the image below.
While your graph will look quite similar to the graph above, it may show a different color for the points or have the grid turned on for example. All of these settings are come from your graphics preference settings.
Changing graphics preferences
To open your graphics preferences, select “Tools->Preferences” from the main menu.
This will open the preferences dialog menu. Select “Graphics” from the left side of the preferences menu.
Towards the top of the graphics preferences window is a list of graph types. To make it easier for you to find, “Scatter” has been highlighted in yellow. To view and change your settings for scatter plots, make sure that the radio button next to “Scatter” is selected.
Just below the listing of graph types is a tab group. The first tab is entitled “Graph Settings”. This tab contains the general settings for the graph such as the title and axes properties, the background color and also the grid which is highlighted in yellow towards the bottom of figure 6.
After the “Graph Settings” tab are five tabs with the title of “Group” followed by a number. These tabs contain the settings for each column of data that you draw on a graph. To change the color, or symbol for the one column of data that you are graphing in this example, click the “Group 1″ tab and customize its settings.
After you have made some changes to the graph, save your changes by pressing the “Apply” button and then the “OK” button. Now run your file again and see your changes reflected in the new graph.