[Top][All Lists]

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

Re: 3d gsplot using first column of z as axis (was Re: timefmt with splo

From: John W. Eaton
Subject: Re: 3d gsplot using first column of z as axis (was Re: timefmt with splot?
Date: Wed, 14 Oct 1998 23:26:24 -0500 (CDT)

On 14-Oct-1998, Colin Telmer <address@hidden> wrote:

| Sorry, perhaps this is more of a pure gnuplot. However, I will try to
| explain what I want to end up with for clarity. I have a 2d array in which
| the columns are different interest rates (maturities ascending from a one
| period rate upwards) and the rows are points through time. So any given
| row is an interest rate yield curve at a given date. I want to plot a 3d
| graph of these yield curve across time. The octave function mesh(z) or
| it's equivalent gnuplot commands from within octave does this exactly.
| Assume that the interest rate is on the z axis, the maturity (each column) 
| is on the y axis and time is on the x axis and the there are 470 rows
| (time points). I wanted to do the same thing as the code within the
| function mesh, but I want to use the values in a vector d as the x axis
| scale rather than 1 through 470 (corresponding to the row index of z). The
| vector d could be anything, but the one I had in mind was
| d = [1952+1/12:1/12:1992+2/12]
| which has length 470 but will look like dates (I understand I could have a
| vector of true dates and use the timefmt stuff in gnuplot, but I have
| become accustom to using this simple hack before discovering the time
| stuff in gnuplot). I'll have to poke around in gnuplot more to see if this
| is possible. If I figure it out I will try to write a function that
| expands mesh to include this ability and forward it to octave-source.

Here is one possibility (using fewer points):

  z = (sort (rand (47, 10)));
  skip = 5;
  d = 1952:1992;
  d_len = length (d);
  s = "gset ytics (";
  for i = 1:skip:d_len-1
    s = sprintf ("%s \"%d\" %d,\\\n", s, d(i), i-1);
  s = sprintf ("%s \"%d\" %d )\n", s, d(d_len), d_len-1);
  eval (s);
  mesh (z);

I realize this is not ideal.  You really need to figure out what skip
factor to use depending on how many data points you are plotting, and
you may want to omit the final tick mark if it is close to the
previous one that was not skipped.


reply via email to

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