GNUPlot-将2D数据点绘制为MPEG [英] GNUPlot - Plot 2D datapoints as MPEG

查看:56
本文介绍了GNUPlot-将2D数据点绘制为MPEG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在x-y列中有一堆点,这是我使用了一些fortran代码完成的.它的一部分看起来像这样

I have a bunch of points in an x-y column, which I made using a bit of fortran code. Part of it looks like this

   1.000          0.000
   0.996          0.063
   0.988          0.125
   0.976          0.187
   0.961          0.249
   0.941          0.309
   0.917          0.368
   0.890          0.426
   0.859          0.481
   0.825          0.535
   0.787          0.587
   0.746          0.636
   0.702          0.682

到目前为止,我可以将所有图像绘制在一张图像中.

and so far, I can plot it all in one image.

但是我需要做的是一次将点绘制成电影.我不想做GIF,因为我需要时间滑块.随着它的移动,我需要用线条将点连接起来.

But what I need to do is to plot the points, one at a time, as a movie. I'd rather not do GIF, as I need the time slider. As it moves, I need to have lines connect the dots.

但是,我发现的所有涉及MPEG的教程都一次绘制一个DAT文件,并将JPEG制作到电影中.像这样,使用gnuplot将电影与数据文件一起使用,但是我没有足够的资源.

However, all the tutorials I've found that involve MPEGs are plotting it one DAT file at a time, and making the JPEGs into the film. Like this one, Make movie with data files using gnuplot, but I don't have enough resources for that.

或者,我尝试遵循以下方法:

Alternatively, I tried to follow this: Gnuplot - plotting position(xyz) vs time data inside a specified space (eg a box) with a pause and then convert it to MPEG, but I can't get their code to work. I get the full plot in all frames, and only the n=# part is animating.

尽管如此,我还是能够制作出动画"f(x,t)".

I was able to get a "plot f(x, t)" animated, though.

(我没有代码为这些点设置动画.真的)

(edit: i have no code to animate the points. really)

推荐答案

要一次设置一个点的动画,可以执行以下操作:

To animate one point at a time, you can do it as follows:

# calculate the number of points
stats 'file.txt' using 1:2 nooutput

# if you want to have a fixed range for all plots
set xrange [STATS_min_x:STATS_max_x]
set yrange [STATS_min_y:STATS_max_y]

set terminal pngcairo size 800,400
outtmpl = 'output%07d.png'

do for [i=0:STATS_records-1] {
    set output sprintf(outtmpl, i)
    plot 'file.txt' every ::::i with lines title sprintf('n = %d', i)
}
set output

最后使用类似的东西

ffmpeg -i pic%07d.png movie.mpeg

转换为电影.

请注意,对于plot,必须使用every ::::i(仅四个:)限制打印点的数量.您链接的问题 Gnuplot-在指定空间(例如一个盒子)内绘制位置(xyz)与时间数据并进行暂停,必须使用五个:来遍历数据,就像用于splot的3D图一样.

Note, that with plot you must use every ::::i (only four :) to limit the number of plotted points. The question you linked, Gnuplot - plotting position(xyz) vs time data inside a specified space (eg a box) with a pause, must use five : to iterate over data blocks, like the are used for 3D-plots with splot.

这篇关于GNUPlot-将2D数据点绘制为MPEG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆