|
From: <pl...@pi...> - 2007-06-02 14:17:03
|
Hi,
in my continued use and testing of assign() patch I was found a limitati=
on =
in using this technique called from plot. This does not ammount to a bug=
=
in assign(), which seems to be pretty solid.
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 start=
ed =
and hence prev_x, prev_y :
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=3D0 as shown. There may be a more eleg=
ant =
solution.
#started=3D0;
reset(x)=3Dassign("started",0.0); # called by dummy plot to ensure =
initialisation on replot
add_aug(x,y)=3Dassign("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/
|