views:

1731

answers:

3

Hi All,

i have a 3 column datafile and i wanted to use splot to plot the same. But what i want is that gnuplot plots first row (in some colour, say red) and then pauses for say 0.3 secs and then moves on to plotting next row (in other colour, not in red, say in green), pauses for 0.3 secs and then proceeds to next row....so on n so forth.

Any help will be greately appreciated.

thanks in advance

Regards Pankaj

+1  A: 

If you want to produce an animation, you better use specialized tools for it (like mplayer).

Use gnuplot to prepare all source images (first one with single row plotted, second - with two lines, etc), then use mplayer or convert (from imagemagic) to produce avi or animated GIF out of source files.

You can use the following shell snippet to produce partial copies of the input file, each with increasing number of lines.

file="your input file.dat"
lines=$(wc -l $file)
i=1
while [ $i -le $lines ] ; do
  head -${i} ${file} > ${file%.dat}-${i}lines.dat
done

Given somefile.dat this will produce files "somefile-1lines.dat", "somefile-2lines.dat", etc. Then you can use:

for f in *lines.dat ; do
  gnuplot ... $f 
done

to plot them all in sequence.

If my assumption is wrong and all you really want is this pause, then you can try to set things up so that gnuplot will get data from stdin, and then use this scipt (name it paused-input.sh) to pipe input file with pauses after each line:

#!/bin/bash
while read l ; do
  echo "$l"
  sleep 1
done

Then invoke it like this:

(pause-input.sh | gnuplot ...) < somefile.dat
ADEpt
A: 

Good attempt but... This will create as many files as the number of lines in data file. This looks ugly to me.

We can write a shell/perl script to create gnuplot script with commands in it like:

splot x1 y1 z1
pause 1
replot x2 y2 z2
pause 1
replot x3 y3 z3
pause 1
replot x4 y4 z4

where xi, yi, zi = coordinates in data file for ith line number. pause 1 will pause it for one sec.

This is just an idea, though am not sure how to plot coordinates directly instead of supplying a data file to gnuplot.

Pankaj
A: 

make a plotfile eg. 'myplotfile.plt'. and put in it all the commands you would normally type in gnuplot to plot your graphs.

then just add the line

!sleep $Number_of_Seconds_to_Pause

to your plot file where you want it to pause, and run it from the terminal with

gnuplot myplotfile.plt

(the extension of the plotfile doesn't matter, if you're on a windows or mac box you might like to use .txt)

example of plotfile:

set title 'x squared'
plot x**2 title ''
!sleep 5
set title 'x cubed'
plot x**3 title ''
!sleep 5
Born2Smile