** Next:** Octave With Grace
** Up:** Drawing Graphs
** Previous:** GNUPlot
** Index**

Click for printer friendely version of this HowTo

One thing to note about using Octave, is that to generate graphs, it
uses GNUPlot, so a lot of the commands are the same.

Here is how to create one of the normal curve graphs that are so common
in the paper:

> x = linspace(-8, 8, 100);
> y = normal_pdf (x);
> plot(x, y)

If we wanted to replace the ``line 1'' label that is the default, we
could change our plot command to add our own version:

> plot(x, y, ``;mu = 0, sigma = 1;'')

To export the graph as a color EPS file, all you need to do is:

> gset term postscript eps color;
> gset output "normal_curve.eps"
> replot

Sometimes when you are using octave, you may want to export the data
that you are working with so you can import it into another graphing
program other than gnuplot (for example, you may want to import the
data into xmgrace). To do this requires a little bit of a trick since
you'll notice that octave exports vectors as a single line with a
whitespace between the elements. While this makes perfect sense to
do, it is often the case that you have a vector representing the values
for the x-axis and a vector (or vectors) representing values on the
y-axis (as we do in the example we just gave). If we were to export
these vectors directly, we'd get the values for the x and the y axis
on two different lines and this is not what we want. Instead, we'd
like to have each line in our output file correspond to a value from
the x-axis vector and a value from the y-axis vector (or values from
y-axis vectors). To do this, you simply create a new matrix that is
made up of the transposes of these vectors. To continue with the
previous example, if we wanted to export our data in a format that
could easily be imported into xmgrace we would do this:

> x = linspace(-8, 8, 100);
> y = normal_pdf (x);
> z = [x', y'];
> save -ascii ``output_file.txt'' z

** Next:** Octave With Grace
** Up:** Drawing Graphs
** Previous:** GNUPlot
** Index**
Click for printer friendely version of this HowTo

Frank Starmer
2004-05-19