From: Ethan A M. <merritt@u.washington.edu> - 2007-06-02 23:59:35
|
On Saturday 02 June 2007 07:17, pl...@pi... wrote: > > The problem occurs in using replot. Since the line defining the initial > conditions only gets executed when loading the .gnu file, calling replot > here gives me an incorrect result by retaining that last values of started > and hence prev_x, prev_y : Your examples are so complicated that I can't see what is supposed to happen. But let me point out that it is perfectly legal to put the definition inside the plot statement, in which case I think it will be re-executed on every "replot". plot started=0, foo(x), baz(x) Ethan > > A work around would be to plot some dummy data before the main plot that > called another function where the variables are initialised. In my case it > is sufficient to reassign started=0 as shown. There may be a more elegant > solution. > > > #started=0; > reset(x)=assign("started",0.0); # called by dummy plot to ensure > initialisation on replot > add_aug(x,y)=assign("area",(started>0)?\ > area + (x-prev_x)*(y+prev_y)/2.0 > + 0.0*(assign("prev_x",x) + assign("prev_y",y) ) \ > : 0.0*( assign("started",1) > + assign("prev_x",x) + assign("prev_y",y) ) \ > ) ; > > plot "init.data" using 1:(reset(0)) t "" \ > , datafile using > 1:(add_aug(strptime("%H:%M",stringcolumn(1))/3600,P( Th4($3-2.0) - Th5($2) > ))/10) axes x1y2 with lines s f t "Energy*100/kWh" > > > best regards/ > > -- Ethan A Merritt Biomolecular Structure Center University of Washington, Seattle 98195-7742 |