help-octave
[Top][All Lists]
Advanced

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

Re: multiplot - solved!


From: Wonkoo Kim
Subject: Re: multiplot - solved!
Date: Wed, 04 Feb 98 06:07:52 -0500

> Date: Tue, 03 Feb 98 11:10:15 -0500
> From: "Wonkoo Kim" <address@hidden>
> Subject: multiplot
>
> I want a few plots on a page, and the number of graphs per plot
> is not fixed but depends on data set.  This variable number of graph
> in a plot works well for one plot mode.  An example code would be
>
>   hold on
>   for k = 2 : ncols+1
>       gplot phi using 1:k with lines
>   endfor
>   hold off
>
> where phi is my function data set in which column 1 has x values,
> the other 'ncols' columns have function values. (You may consider
> them as 'ncols' channels of signals.)  I want to plot them together
> in a plot.  This number 'ncols' is determined by input data file.
> There was no problem in ploting until I tried multiplot.
> ...
> Could you suggest any other better way?
> (I know the above loop generates multiple 'plot' commands rather than
> just one plot command like "plot data using 1:2 w l, using 1:3 w l,
> ...", but I couldn't find a good solution.)

The Octave author hinted me about eval() function, and I could make 
the above multiple gplot commands generated by loop into a single 
gplot command.  Here is my final code:

plotcmd = "";
for k = 2 : ncols
   # ttl = sprintf ("sf-%d", k-1);
   # gplot phi using 1:k title ttl with line
   plotcmd = sprintf ("%s, phi using 1:%d title \"sf-%d\" with lines", ...
                        plotcmd, k+1, k);
endfor
eval (sprintf ("gplot phi using 1:2 title \"sf-1\" with lines%s", plotcmd));

This will generate only one plot, so I don't get multiple misaligned 
axes and lines, and "hold on" command is no longer needed.  This is a 
perfect solution that I need for screen preview.

> Another quick question:  How do I clear plot in multiplot mode?
> I get accumulated plots unless I close gnuplot window, even after
> clearplot.  Single plot mode works fine, though.

José Daniel Muñoz Frías <address@hidden> suggested me to switch
back to single plot mode to clear gnuplot window.  This was quite a
good work-around.  Calling multiplot(0,0) (instead of clearplot)
before any multiplot did work fine.

Thanks a lot! 

//--------------------------------------------------------------------
// Wonkoo Kim (address@hidden)



reply via email to

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