A graphic I can (hardly) do in gnuplot, but not at all in octave

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

A graphic I can (hardly) do in gnuplot, but not at all in octave

Cautaerts Vincent
Hello,

I need some help for creating a graphic. Actually, I can not do it
easily under "gnuplot", but maybe there is a good way to do this kind
of things. When doing it from gnuplot, I have to manually change
the data file, which I cannot do everytime under octave !

In brief, I make some simulations of pulses, and I would like to have
something like this (let's try ASCII art...)

y axis
|
|    z axis
|     /          .
|    /       . .   .  * *
|   /      .       *.     *
|  /  .....      *    . ...*............
| /             *            *
|/**************               ************
-----------------------------------------------> x axis
where *** is supposed to be one line, and .... another.

If I use "mesh", I have a complete grid: i.e. also lines from some "*" to
some "."

Seen from the top of the y axis:
  WHAT I HAVE          WHAT I'D LIKE         z axis
+--+--+--+--+--+       -------------         |
|  |  |  |  |  |                             |
+--+--+--+--+--+       -------------         +-----> x axis
|  |  |  |  |  |
+--+--+--+--+--+       -------------
...

If possible, I would like to have hidden lines, i.e.
y axis
|
|    z axis
|     /          .
|    /       . .   .  * *
|   /      .       *      *
|  /  .....      *         *............
| /             *            *
|/**************               ************
-----------------------------------------------> x axis

Then, if somebody
1) understands what I mean
2) knows how to do it
please tell me !

When using mesh, I use the command:

mesh(Memory_z',t',abs(Memory_v)');

where "Memory_z" is for example a [1 5] vector, with the z coordinates
                      of my pulses (thus 5 here)
      "t" is a [1 128] vector with the datas for the x axis
      "Memory_v" is a [5 128] vector with the datas:
Memory_v(1,:) contains the first curve
Memory_v(2,:) the second,...

I'de like to plot, on a 3d graph, the curves
Memory_v(1,:) versus t  in the plane z=Memory_z(1) (represented with ** here)
Memory_v(2,:) versus t  in the plane z=memory_z(2) (represented with .. here)
...

If possible, I'de like to have surface hiding.
[ This representation is very often in my field to show
how does some pulses evolve when propagating ]

So, can somebody help me ?

[ I couldn't find how to do this in the gnuplot doc, nor in the
octave one. When doing it under gnuplot, the trick is to erase the
first data of the first curve, such that gnuplot can not see anymore
relations between the different curves, and then draw then individually.
Still, there is no surface hiding ]

By the way: I found some rpm (for RedHat) files with octave, but
I can't remember where. Does anybody knows ?

Thanks to all of you who read up to here !

--

Vincent Cautaerts
Quote of the day/week/month:
  Computers are not intelligent.  They only think they are.


Reply | Threaded
Open this post in threaded view
|

A graphic I can (hardly) do in gnuplot, but not at all in octave

John W. Eaton-6
On  2-Sep-1997, Cautaerts Vincent <[hidden email]> wrote:

| Hello,
|
| I need some help for creating a graphic. Actually, I can not do it
| easily under "gnuplot", but maybe there is a good way to do this kind
| of things. When doing it from gnuplot, I have to manually change
| the data file, which I cannot do everytime under octave !
|
| In brief, I make some simulations of pulses, and I would like to have
| something like this (let's try ASCII art...)
|
| y axis
| |
| |    z axis
| |     /          .
| |    /       . .   .  * *
| |   /      .       *.     *
| |  /  .....      *    . ...*............
| | /             *            *
| |/**************               ************
| -----------------------------------------------> x axis
| where *** is supposed to be one line, and .... another.
|
| If I use "mesh", I have a complete grid: i.e. also lines from some "*" to
| some "."
|
| Seen from the top of the y axis:
|   WHAT I HAVE          WHAT I'D LIKE         z axis
| +--+--+--+--+--+       -------------         |
| |  |  |  |  |  |                             |
| +--+--+--+--+--+       -------------         +-----> x axis
| |  |  |  |  |  |
| +--+--+--+--+--+       -------------
| ...
|
| If possible, I would like to have hidden lines, i.e.
| y axis
| |
| |    z axis
| |     /          .
| |    /       . .   .  * *
| |   /      .       *      *
| |  /  .....      *         *............
| | /             *            *
| |/**************               ************
| -----------------------------------------------> x axis
|
| Then, if somebody
| 1) understands what I mean
| 2) knows how to do it
| please tell me !
|
| When using mesh, I use the command:
|
| mesh(Memory_z',t',abs(Memory_v)');
|
| where "Memory_z" is for example a [1 5] vector, with the z coordinates
|                       of my pulses (thus 5 here)
|       "t" is a [1 128] vector with the datas for the x axis
|       "Memory_v" is a [5 128] vector with the datas:
| Memory_v(1,:) contains the first curve
| Memory_v(2,:) the second,...
|
| I'de like to plot, on a 3d graph, the curves
| Memory_v(1,:) versus t  in the plane z=Memory_z(1) (represented with ** here)
| Memory_v(2,:) versus t  in the plane z=memory_z(2) (represented with .. here)
| ...

I think gnuplot (and Octave) can almost do what you want.  In Octave,
create a matrix that includes the lines you want to plot, like this:

  data = [x1, y1, z1, x2, y2, z2, ..., xn, yn, zn];

where each x1, y1, z1, etc., represents a column of data.  Then set
gnuplot's parametric plotting mode and plot the matrix using gsplot:

  gset parametric
  gsplot data

For example:

  x = (0:0.2:6)';
  n = length (x);
  z = zeros (n, 3*n);
  for i = [1:n-2, n, n-1]
    z(:,3*i-2) = x;
    z(:,3*i-1) = i;
    z(:,3*i) = [sin(x(i:n)); sin(x(1:i-1))];
  endfor
  gset parametric
  gplot data

The problem is that if your data looks like it forms a grid (and this
matrix will), then gnuplot seems to want to draw the mesh lines.  So
far, the only way I've found to turn this feature off involves editing
the generated data file, or by creating the data file for gnpulot
using fprintf.  There may be a more convenient way, but I
haven't found it yet.

jwe