From help-octave-request at bevo dot che dot wisc dot edu Wed Feb 4 05:26:35 1998 Subject: Re: multiplot - solved! From: "Wonkoo Kim" To: "Octave Users" Date: Wed, 04 Feb 98 06:07:52 -0500 > Date: Tue, 03 Feb 98 11:10:15 -0500 > From: "Wonkoo Kim" > 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 =3D 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 =3D ""; for k =3D 2 : ncols # ttl =3D sprintf ("sf-%d", k-1); # gplot phi using 1:k title ttl with line plotcmd =3D sprintf ("%s, phi using 1:%d title \"sf-%d\" with lines", = =2E.. 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=E9 Daniel Mu=F1oz Fr=EDas suggested me to swi= tch 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 (wkim+ at pitt dot edu)