Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gif Animation in Gnuplot

I have a data file separated by two lines. Each section of data is ~50 lines. I'm trying to make a .gif file. I know how to plot them individually or in a group but can't get the .gif to work.

My problem is similar to the one worked out by Glen MacLachlan in his youtube channel, part 5. Instead of 1 point, I have ~50 data points for each data section. He solves the problem by utilizing $index feature, and I tried to do the same but mine doesn't work.

What am I missing? Do I really have to plot the data separately into .png files and group them together to get .gif file?

What I've done:::

I edited the data file. Previously there were two columns x, and y. Now, I have them in 2nd and 3rd column, and the first column is index from 0 to 50. Each block of data has similar index.

bash script to create plot file

for ((i=0;i < 50; i++)) do echo "plot 'data.txt' 
u 2:3 w circles index $i"; done >>simulate.plt

It just plots ALL the data points

like image 914
timmur Avatar asked Apr 06 '14 19:04

timmur


1 Answers

Why don't you show what you have tried?

The following should work fine:

set terminal gif animate delay 100
set output 'foobar.gif'
stats 'datafile' nooutput
set xrange [-0.5:1.5]
set yrange [-0.5:5.5]

do for [i=1:int(STATS_blocks)] {
    plot 'datafile' index (i-1) with circles
}

with the file datafile:

0
1


2
3


4
5

gives

enter image description here

like image 132
Christoph Avatar answered Oct 18 '22 22:10

Christoph