help-octave
[Top][All Lists]

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

 From: Colin Telmer Subject: 3d gsplot using first column of z as axis (was Re: timefmt with splot? Date: Tue, 13 Oct 1998 14:22:01 -0400 (EDT)

On Thu, 8 Oct 1998, Dirk Eddelbuettel wrote:

>   Colin> I have tried to use "using" but I cannot figure out what arguments
>   Colin> to pass to it. Any ideas?
>
> I tried similar things with 2d plots, and it failed exactly there.

I could get it going with 2d plots, but not with 3d as it is the entire
matrix z I wanted to plot. With 2d plots, if I have the first column in
the appropriate date format, I could do something like using 1:3 to plot
column 3 against the dates in 1.

Perhaps a simpler or more general way to ask my question is "how can I
plot a matrix z using a vector (with the length equal to the number of
rows in z) as the corresponding plot axis rather than the simple row index
of z (which is default)?"

As an aside Dirk, I found a interesting hack to make, say the x axis, of a
2d plot in a rough time format. For a monthly data series called x, set up
a vector as follows:

dates =[1952+1/12:1/12:1992+3/12];
gplot [dates,x] using 1:2 (something like that - I am at work)

Works great for me. What I would like to do is use "dates" as the numbers
on an axis in an gsplot. Cheers.

>
> However, I got it to work starting from a working setup in 'plain gnuplot'
> (ie outside of Octave) and to then to pass those very commands to gnuplot
> in a pipe. Ie
>
>   fid = popen("gnuplot", "w");
>   fputs(fid, "set timefmt \"%Y%m%d\"\n");       <---------- parse time
>   fputs(fid, "set xdata time\n");               <---------- & display time
>   fputs(fid, "set format x \"%m/%y\"\n");       <---------- this way
>
> [... more settings omitted ...]
>
>   fputs(fid, sprintf(["plot [\"%d\":\"%d\"] \"%s\" u 1:2 ax x1y1, ", \
>                       "'' u 1:3 ax x1y2\n"], \
>                      fromdate, todate, tmpfile));
>   pclose(fid);
>
> You can also write your data to the same pipe, try 'help plot datafile'
> from within gnuplot.
>
> Hope this helps,  Dirk
>
> --
> Linux is not only free; it is, arguably, a better operating system, offering
> a degree of stability and an ability to scale up that NT cannot match.
>                                              -- The Economist, Oct 3, 1998
>

--
Colin Telmer, Ottawa, Ontario, Canada