[lug] math plots, gnuplot, octave

J. Wayde Allen wallen at lug.boulder.co.us
Mon Oct 29 11:34:36 MST 2001


On Thu, 25 Oct 2001, D. Stimits wrote:

> I'm not sure if gnuplot can work in 3D, e.g., display of a bezier
> surface, I'm looking to do this as well (long ago I had a student
> edition of Mathematica, but it expired).

Yes, gnuplot can do 3D surfaces.  The command you need is splot.  It also
sounds like you need to do some browsing at
<http://www.gnuplot.org/>.  There are some demo's that include 3D plotting
at <http://www.gnuplot.vt.edu/gnuplot/gpdocs/all2.htm>.

I've done a few 3D plots, but typically only scatter plots rather than
contoured surfaces.  Based on the limited info you've given, it sounds
like you could either write a computer program to generate your data to be
plotted, or create a mathematical function directly in gnuplot and then
have the program plot the function.  You can get help on this by starting
gnuplot and typing:

   help expressions

I usually tend towards generating data with a standalone program and
plotting it as a separate step, but either approach should work.

> If I set terminal to latex, I can generate
> some for of latex output, but so far I haven't figured out what I'm
> missing (running latex on the generated file fails...I'm thinking I have
> to embed this file inside another).

This generates LaTeX code that you would insert in a LaTeX document so
that the LaTeX processor can draw the graph itself.  I've tried it and it
works, but the fonts left a lot to be desired.  Yes, that should be
changeable, but it wasn't a battle I wanted to fight.  What I do is set
the gnuplot to generate encapsulated postscript:

   set term postscript eps 
   set output "myplot.eps"
   replot

Then you simply drop these into the LaTeX page using the graphics
utility.  Let's see, from an old document where I was using the now
deprecated psfig module you'd put the following lines in the LaTeX header:

   \usepackage{psfig}           % Use psfig for figures
   \psfigurepath{./figures}     % Setup the figure path

and include a figure like:

   \begin{figure}
      \centerline{\psfig{figure=myplot.eps}}
      \caption{This is a plot of the file myplot.eps}
      \label{fig:myplot.eps} 
   \end{figure}

It would be better to use graphics or graphicsx, but the technique is the
same.  You'll have to look up the graphics commands and replace the \psfig
stuff accordingly.

> Can anyong give me an idea of 3D plots are possible in gnuplot?

Yes, they are possible.

> Or how to process the TeX output for image creation? Maybe alternate
> means of creating graphics output with the goal being images,
> postscript, or pdf?

However you want really.  I create eps images and drop them into the
document.  However, using the newer graphics packages in LaTeX allows you
to use other formats than eps.

> I guess octave is a high level system that uses gnuplot, other than
> that, I'm not sure what to expect from it, I'm wondering if anyone here
> has any experience with it for interactive use?

Ocatave is much like matlab.  I've played with it a bit, but that's about
it.  If you just need a 3D plot you probably don't need Octave.

> Any favorite URL's for these subjects?

   http://www.gnuplot.org/
   http://www.octave.org/

- Wayde
  (wallen at lug.boulder.co.us)




More information about the LUG mailing list