1

My intention is to have loaded variable i in for cycle - I want to have it usable for this cycle. Current state is that gnuplot loads var i from the first echo as a string not var.

SPEED=5

echo "plot '< head -n \"\$((SPEED*i))\" `echo ${INFILE}`' using 1:3 ;">> file.plt

for ((i=1;i<="$FRAMES";i++))                                     
do      
    echo  " 
        load '`echo ${file.plt}`';  
        " | gnuplot
done
Anders Lindahl
  • 41,582
  • 9
  • 89
  • 93
Petr Marek
  • 1,381
  • 1
  • 15
  • 31

1 Answers1

2

I think you can probably do all of this in gnuplot directly...

if(! exists("N")) N=0
FRAMES=10
FILE='myfile.plt'
SPEED=5
f(i)=sprintf("< head -n %d ".FILE,i+SPEED)
plot f(N) using 1:3
if(N < FRAMES) N=N+1
if(N < FRAMES) reread

Gnuplot 4.6 makes this even easier:

do for [N=1:10]{
   FILE='myfile.plt'
   SPEED=5
   f(i)=sprintf("< head -n %d ".FILE,i+SPEED)
   plot f(N) using 1:3

}


and instead of using head, you can probably use the every datafile modifier (help every for details). I think something like the following:

NPT=N+SPEED
plot FILE every ::::NPT using 1:3
mgilson
  • 300,191
  • 65
  • 633
  • 696
  • 1
    gnuplot rocks! Thanks for sharing. – shellter May 10 '12 at 13:29
  • @shelter There's also plot iteration in gnuplot 4.3+, but I think that would have a different result (it would put all the plots on the same graph) as opposed to having each of the plots in their own graph. – mgilson May 10 '12 at 14:29