plot3() ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

plot3() ?

Jeppe Sigbrandt
Hiya,

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 :)

Thanks,
jay


Reply | Threaded
Open this post in threaded view
|

plot3() ?

John W. Eaton-6
On 23-Jul-1996, Jeppe Sigbrandt <[hidden email]> wrote:

: 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 :)

In gnuplot, all you have to do to plot a line in 3d is

  set parametric
  splot "foo.dat" with lines

where "foo.dat" contains 3 columns of data (x y z).

Blank lines in the data file produce breaks in the line.

An example of this should be in the glass demo that is distributed
with gnuplot.

You should be able to do the same thing with Octave using set
parametric and the gsplot command.

jwe

Reply | Threaded
Open this post in threaded view
|

Re: plot3() ?

Ted.Harding
In reply to this post by Jeppe Sigbrandt
( 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.                                    ([hidden email])