help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: plot3() ?


From: Ted Harding
Subject: Re: plot3() ?
Date: Tue, 23 Jul 1996 23:11:52 +0100 (GMT+0100)

( Re Message From: Jeppe Sigbrandt )

> Is it possible to do what plot3() does in Matlab ? 
> 
> e.g. Lorenz demo where a line is drawn in phase space by joining
> up the points represented by  a sequence of xyz co-ordinates. 
> 
> I've spent  many hours trying to obtain this simple 
> behaviour from Gnuplot but the answer has not yet dawned on me.
> And nobody seems to have asked this question in the last 2 years.
> (so it must be easy :)

I agree it is some way short of obvious. First suss out how to do it in
raw gnuplot with a data-file; then in octave do "help plot" and notice
that the equivalent octave construction uses "gsplot" rather than "splot":
and you're probably there.

Example:

octave:13> t=0.01*(0:100)'*2*pi;
octave:14> X=[cos(t).*cos(t) cos(t).*sin(t) sin(t)];
octave:15> set parametric
octave:16> gsplot X with lines

Having got this far, you can define your plot3 function:

octave:17> function plot3(X)
> set parametric
> gsplot X
> endfunction
octave:18> clg; plot3(X)

You can then fancy this up by allowing for gnuplot options like "with
points" (gsplot does it by default with lines) in the function arguments,
but you'll have to start using "eval" at this point, I guess:

octave:29> function plot3(X,s)
> set parametric
> plot_data=X;
> eval(["gsplot plot_data " s]);
> endfunction
octave:30> clg; plot3(X,"with points")
octave:31> clg; plot3(X,"with lines")
octave:32> clg; plot3(X,"with linespoints")

All the best,
Ted.                                    (address@hidden)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]