gnuplot动画矢量图 [英] Gnuplot animation vector
问题描述
我正在尝试在gnuplot中制作流畅的矢量动画.要创建矢量值,我使用FORTRAN.我的FORTRAN子例程程序将矢量数据打印在一个名为vekdata.txt的txt文件中,并使用gnuplot命令创建另一个名为plotvek.txt的文件.该子例程位于do循环内,因此每次迭代都会更新vekdata.txt.
i am trying to make a fluid vector animation in gnuplot. To create the vector values i use FORTRAN. My FORTRAN subroutine program prints vector data in a txt file called vekdata.txt and creates another file called plotvek.txt with gnuplot commands. This subroutine is inside a do loop so for every iteration vekdata.txt gets updated.
所以我一直在徘徊着如何随着时间的推移制作动画呢?有一些简单的命令吗?现在,它可以将大量图片打印到我的屏幕上.每张图片都有点不同,所以我知道代码可以工作.
So i was wandering how i can make an animation of this as it develops in time? Is there some simple commands? As it is now it prints a huge amount of picture to my screen. Every picture is a bit different so i know the code works.
do t=1,1000
call vektorplot(storu,storv,n,Re,t)
end do
open(21,access='sequential',file='plotvek.txt',status='unknown')
write(21,*)'set term png enhanced'
write(21,*)'# plotvek.txt'
write(21,*)'set output sprintf(''frame_%09d.png'',',t,')'
!animation commands
write(21,*)'set output sprintf("frame_%9d",'t,')'
close(21,status='keep')
call execute_command_line("gnuplot -persist plotvek.txt")
推荐答案
我在这里发布了另一种方法.
I'm posting here an alternative.
尽管我通常更喜欢将gif动画用作 Karl答案,但有时很难租借太大的gif,尤其是对于较长的电影,它们往往会创建无响应的应用程序(浏览器或幻灯片演示文稿).
Although I usually prefer the animated gif as Karl answers, sometimes too big gifs are difficult to rented and especially for very long movies, they tend to create unresponsive applications (browser or slide presentations).
基本上,您每帧写入一个文件,然后创建电影.
Basically you write to a file every frame and then create a movie.
在此链接中,您同时拥有gif和电影示例.我将在这里回顾这些原则.
In this link you have both gif and movie examples. I'm going to recall here the principles.
为每个帧设置一个png终端并输出文件.作为fortran命令,它类似于:
For every frame you set a png terminal and output file. As fortran command, this would be something like:
write(21,*)'set term png enhanced'
write(21,*)'# plotvek.txt'
write(21,*)'set output sprintf("frame_%09d.png",',n+1,')'
[...]
然后,程序运行后,您可以创建电影:
Then, once the program is run, you can create a movie:
mencoder mf://frame_%09d.png -mf fps=30 -ovc lavc -o my_video.avi
当然,mencoder有很多选择来调整电影.
Of course mencoder has a tons of options to tune your movie.
mencoder
的另一种替代方法是ffmpeg
:
Another alternative to mencoder
is ffmpeg
:
ffmpeg -framerate 1/5 -i frame_%09d.png -c:v libx264 -r 30 -pix_fmt yuv420p my_video.mp4
这篇关于gnuplot动画矢量图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!