4. A simple example

When you activate plotdata a welcome message followed by the first PLOTDATA: prompt is printed in the text window, and another window pops up, the one in which plotdata will display the graphics. Only one window can be active at any given time, so you may need to move the mouse inside the window that you want to ``connect'' your keyboard to. You may want to resize and/or move the text window around so that you can see both at the same time. Do not resize or close the graphics output window; it will get closed automatically when you exit plotdata.

Let's assume you have started plotdata successfully. At PLOTDATA: prompt type the following:

PLOTDATA: x={1,2,3,4,5,6,7,8,9}
PLOTDATA: y={0.05,0.10,0.14,0.19,0.25,0.30,0.34,0.40,0.45}
PLOTDATA: graph x,y

Your graphics window should be showing the graph of y vs. x! (You can jump ahead and take a peak at Figure 1 if you are not running plotdata, typing these commands as you go along).

The above data could have been something like time and distance from one of your air track experiments. In fact, we should have also entered the error bars at each data point, like this:

PLOTDATA: dy={0.02,0.07,0.01,0.04,0.05,0.10,0.02,0.04,0.04}
PLOTDATA: clear
PLOTDATA: graph x,y,dy

We have used clear to clear the graph and start a new one with the next graph command.

You can immediately see that the dependence is roughly linear. Let us investigate closer. First of all, the line connecting the points is really inappropriate, since we only made a discrete set of measurements and really know nothing about what y(x) is like in between our data points. To fix that, we will change one of the settings of plotdata, that of the plotting character, or pchar.

PLOTDATA: pchar -10
PLOTDATA: clear
PLOTDATA: graph x,y,dy

Now each data point is indicated by a triangle (the plotting character No. 10), and there is no line connecting the data points (the minus sign in front of 10).

Now we are free to use a line to indicate a theoretical model that fits this data. From the way we generated our data (air track) we expect a linear dependence. Let's fit the data to a linear expression:

PLOTDATA: vary a
PLOTDATA: fit y=a*x

The output generated by plotdata, among other things, tells us that the best value for the parameter a is 0.0495+/-0.0039. The error in the fit is given by the standard deviation (the E2 parameter), and there are some other useful numbers reported which we will ignore for now.

Armed with this best fit, we can add a ``theoretical'' line to our experimental plot. We can recalculate what the values should have been if the experiment yielded exactly the linear dependence we expect, by ``updating'' a new vector, f, to contain the values that the last fit command had calculated:

PLOTDATA: update f
PLOTDATA: pchar 0
PLOTDATA: graph/noaxes x,f

Two points of interest here: we used pchar 0 to turn the plotting character to none and the line through the points to on, and then we used a switch (/noaxes) on the graph command to add the second graph to the already existing one. Looks pretty cool.

To add the final touches, let's label things properly:

PLOTDATA: xlabel "Time, s"
PLOTDATA: ylabel "Distance, m"
PLOTDATA: replot

Figure 1 shows what your plot should look like at this point.


PostScript file
Figure 1. A simple example. Plotting data points with error bars. The fit to a linear equation is shown as a solid line.

Before we advance on to more elaborate things you must learn how to end your plotdata session. The magic word is quit. Try it now.

One remark: your graph may look slightly different. In creating Figure 1 I had doubled the size of the plotting character to 2% of the page width, up from the default 1%, using the command:

PLOTDATA: set %charsz 2

before the graph command. It's one of those slightly more advanced commands that we will get to soon.



Up: Table of contents Next: 4.1 Reading data into plotdata Previous: 3. Hardware