Say, you have many files with two columns of data.  If we want to plot the data in each file in a separate plot, it will take a lot of time do it manually one by one. But using a simple shell script, this can be done at once.

Let the files be named as data1, data2, data3, …, dataN. An example shell script plot for doing this looks like:

for i in `seq 1 N`;
gnuplot << plotting_many_files
set xlabel "x"
set ylabel "y"
set terminal pngcairo
set output "$name.png"
plot xy using 1:2 with dots

This script is assuming that all the data files are in the same location as the script file. Also it creates png figures with the same name as data files. Replace N with the number of the last file. For running this script in terminal, you have to enter the command,

sh plot

For creating an animation from the plots created as above, we need the image editing software GIMP.


  1. Open GIMP

  2. File > Open as layers

  3. Select all the plotted figures and open

  4. File > Save as

  5. Choose GIF and enter a name for the animation

  6. Select ‘Save as animation’ when prompted

  7. You can specify some parameter of the animation in this window. Like delay between frames, loop forever, etc. Default choices are okay for most purposes.

  8. Enjoy !!