<!–Converted with LaTeX2HTML 2022 (Released January 1, 2022) –> <HTML lang="en"> <HEAD> <TITLE>Contents of 2-D Plotting</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> <META NAME="viewport" CONTENT="width=device-width, initial-scale=1.0"> <META NAME="Generator" CONTENT="LaTeX2HTML v2022">
<LINK REL="STYLESHEET" HREF="rlabp_tex.css">
<LINK REL="next" HREF="node49_mn.html"> <LINK REL="previous" HREF="node47_mn.html"> <LINK REL="up" HREF="node47_mn.html"> <LINK REL="next" HREF="node49_mn.html"> </HEAD>
<BODY bgcolor="#ffffff" text="#000000" link="#9944EE" vlink="#0000ff" alink="#00ff00">
<H2><A ID="SECTION000121000000000000000"> 2-D Plotting</A> </H2>
<P> To plot some data with a minimum of effort do:
<P> <PRE> > data = (0:pi:.1)'; > data[;2] = cos (2*pi*data*3); > pstart („"xwin"); > plot (data); </PRE>
<P> The <code>pstart</code> function was called with the default sub-plot definition (1 subplot), and the X-windows driver as the display device. The <code>plot</code> function accepts matrices, or lists as arguments and plots the columns of a matrix, or the columns of each matrix of a list.
<P> Now for a slightly more complex example.
<P> <PRE> > 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"); </PRE>
<P> <P>
<DIV class="CENTER"><A ID="p1"></A><A ID="507"></A> <TABLE> <CAPTION class="BOTTOM"><STRONG>Figure:</STRONG> Example Plot</CAPTION> <TR><TD><IMG STYLE="height: 286.76ex; " SRC="img7.png" ALT="
<P> 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 <code>pstart</code> 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 <code>ptitle</code> and <code>xlabel</code> function calls effect the first sub-plot. The first call to <code>plot</code> creates the first sub-plot. The subsequent calls to <code>ptitle</code>, <code>xlabel</code> and <code>ylabel</code> effect the second sub-plot, and the last call to <code>plot</code> creates the second sub-plot.
<P> The last line is a call to <code>plprint</code>. The <code>plprint</code> function creates a file that contains a copy of the contents of the current plot-window. The default hardcopy device for <code>plprint</code> is Postscript, but color Postscipt, Xfig, plmeta, and HP-LJII can also be specified. The output from <code>plprint</code> is presented in Figure <A HREF="node48_ct.html#p1"><IMG ALT="[*]" SRC="crossref.png"></A>.
<P>
<HR>
</BODY> </HTML>