You should keep all data plots in layer and just control their Show property. The following script should work
// count number of plots in layer and set all to be hidden
layer.color=color(white);//need to have a color to clear background with plot -l
nplots=0;
doc -e D {set %C -s 0;nplots++};
set %(1,@D) -s 1;// show 1st plot
plot -l; // draw layer
loop (i,2,nplots) {
sec -p 1;
set %(i-1,@D) -s 0;
set %(i,@D) -s 1;
plot -v; // disable flash
plot -l;
};