2-D Plotting

To plot some data with a minimum of effort do:

> data = (0:pi:.1)';
> data[;2] = cos (2*pi*data*3);
> pstart (,,"xwin");
> plot (data);

The pstart function was called with the default sub-plot definition (1 subplot), and the X-windows driver as the display device. The plot function accepts matrices, or lists as arguments and plots the columns of a matrix, or the columns of each matrix of a list.

Now for a slightly more complex example.

> t = (0:10:.05)';
> x = exp (-0.5*t) .* (cos (2*pi*3*t) + sin (2*pi*7*t));
> X = fft (x);
> rfile faxis
> freq = faxis (X, .05, 3);
> mag = abs (X);
> rfile angle
> phase = angle (X);
> pstart (1,2,"xwin");
>
> ptitle ("Magnitude of FFT")
> xlabel ("Frequency (Hertz)");
> plot ([freq,mag]);
>
> ptitle ("Angle (atan2(imag/real)) of FFT")
> xlabel ("Frequency (Hertz)");
> ylabel ("Angle (radians)");
> plot ([freq,phase]);
> plprint ("p3.ps");

Figure: Example Plot
\begin{figure}\begin{picture}(350,350)(0,50) % (x-size, y-size) (x-shift, y-shif...
...angle=90 hscale=60 vscale=60 voffset=40 hoffset=460}
\end{picture}
\end{figure}

In this example we create a plot-window with two subplots so that we can display related information on the same plot-window. The arguments to pstart specify that there will be 1 plot in the horizontal direction, and 2 plots in the vertical direction, thus creating 2 sub-plots. The first ptitle and xlabel function calls effect the first sub-plot. The first call to plot creates the first sub-plot. The subsequent calls to ptitle, xlabel and ylabel effect the second sub-plot, and the last call to plot creates the second sub-plot.

The last line is a call to plprint. The plprint function creates a file that contains a copy of the contents of the current plot-window. The default hardcopy device for plprint is Postscript, but color Postscipt, Xfig, plmeta, and HP-LJII can also be specified. The output from plprint is presented in Figure [*].