Gnuplot: how to build each line in a file after a pause

I have a 3-column data file and I wanted to use splot to build it. But I want gnuplot to occupy the first row (in some color, say red), and then stop for 0.3 seconds, and then proceed to build the next row (in a different color, and not in red, for example, green), pause for 0.3 secs, and then proceeds to the next line .... so on n and on.

Any help would be greatly appreciated.

early

Regards Pankai

+5
source share
4 answers

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

gnuplot ( , - ..), mplayer convert (from imagemagic) avi GIF .

, .

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

somefile.dat, "somefile-1lines.dat", "somefile-2lines.dat" .. :

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

.

, , , , , gnuplot stdin, scipt (name it paused-input.sh) :

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

:

(pause-input.sh | gnuplot ...) < somefile.dat
+2

, ... , . .

/perl script gnuplot script , :

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

xi, yi, zi = i- . 1 .

, , , gnuplot.

+2

( ), , gnuplot ( 4 ).

for -loop every, :

# Find out the number of lines in the data somehow, 
# for example like this:
num_lines="`cat my_datafile.d | wc -l`"

# Plot the first line in the data-file:
plot './my_datafile.d' every 1::0::0

# For the remaining lines:
do for [line_index = 1:num_lines-1] { 
  pause 0.3
  # Replot (from the same datafile) each line 
  # in the data file from the first one up to 
  # the current line_index 
  replot '' every 1::0::line_index
}

every 1::0::line_index gnuplot - - (1) (0) line_index. <point_incr>, <start_point> <end_point>, gnuplot:

 gnuplot> help every
 The `every` keyword allows a periodic sampling of a data set to be plotted.
 [...]

 Syntax:
    plot 'file' every {<point_incr>}
                       {:{<block_incr>}
                         {:{<start_point>}
                           {:{<start_block>}
                             {:{<end_point>}
                               {:<end_block>}}}}}
 [...]

:

$ gnuplot --version
gnuplot 4.6 patchlevel 0
+1

create a graph file, for example. 'Myplotfile.plt. and enter into it all the commands that you usually enter in gnuplot for plotting.

then just add the line

!sleep $Number_of_Seconds_to_Pause

to the chart file where you want to pause it and run it from the terminal using

gnuplot myplotfile.plt

(the plot file extension does not matter if you are in a Windows or Mac window, you can use .txt)

example plot file:

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

All Articles