Make movie with data files using gnuplot

前端 未结 1 1717
日久生厌
日久生厌 2021-02-04 16:37

I do have many data files. They look like 1.dat 2.dat .... .... 1000.dat

I want to make a movie using these files plotting them in sequence. Does anyone have any idea

相关标签:
1条回答
  • 2021-02-04 17:07

    You need two steps here. The first one is to create jpeg or png plots from the data. I do not know what your data looks like, but I guess you've already found out how to plot it with gnuplot. Gnuplot has a loop option, but if you're on a linux box, you can easly pass all the files to gnuplot as arguments for example, run the following in bash:

    for i in {1..1000}
    do
       gnuplot "What needs to be done" $i.dat
    done
    

    Now, you need to create your movie. The easiest way would be:

    ffmpeg -i gnuplotoutput%04d.jpeg movie.mpeg
    

    Edit: After your clarification (the data is 3d etc):

    for i in {1..1000}
    do
       gnuplot -e "set terminal jpeg; splot '$i.dat'" > pic$i.jpeg
    done
    
    ffmpeg -i pic%04d.jpeg movie.mpeg
    

    Indeed, the idea was that "what needs to be done " will be replaced by your own commands. gnuplot is exceptionally capable, but you need to tell it exactly what to do. That depends on your data, and what output you want. I've used splot, to create a 3d grid graph.

    0 讨论(0)
提交回复
热议问题