Gnuplot 中的动态绘图(在 MATLAB 中绘制)
是否可以在 Gnuplot 中创建动态图?为了实现我的目的,我需要的是,当数据是通过某个循环生成时,我将使用 gnuplot 在 xy 轴上放置一些标记,以保留旧的标记。因此,我将能够以某种方式观察数据的演变,而不仅仅是看到最终的批次结果。
我特别想要的是相当于MATLAB中的“drawnow”命令。
虽然不完全相关,但现在我正在使用 common lisp 在循环和 cgn 中生成数据,以便使用 gnuplot 在 lisp 中进行绘图。 (我可以使用使用 gnuplot 的 cgn 在 common lisp 中以批处理形式绘制数据)
提前非常感谢您的关注。
编辑:我为此目的用 common lisp 编写了一段代码。您可以在这里查看:
使用 Common Lisp 和 Gnuplot 按顺序绘制来自 emacs 的数据
然而,这个线程更通用,要求在 gnuplot 中进行动态绘图。欢迎任何建议。
Is it possible to create dynamic plots in Gnuplot? What I require for my purposes is that, as the data is generated through some loop, I will use gnuplot to put some marker on the x-y axis preserving the older ones. So somehow I will be able to observe the evolution of the data instead of just seeing the final batch result.
What I specially want is equivalent to "drawnow" command in MATLAB.
Although not totally related, right now I am using common lisp to generate the data in a loop and cgn in order to plot within lisp using gnuplot. (I can plot data in batch form inside common lisp using cgn which utilizes gnuplot)
Thank you very much in advance for your attention.
edit: I have a written a code in common lisp for this purpose. You can check it here :
Plotting data sequentially from emacs using Common Lisp and Gnuplot
This thread is however more general and asks dynamic plotting in gnuplot. Any suggestions are welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定我是否完全理解您的要求,但如果您想在绘制的最后一个字符串中添加一个绘图(并且您正在使用 gnuplot 4.4),则以下方法可以解决问题:
无论如何,我'我不确定这是否是您所要求的,因为我不使用 Matlab,但我希望如此。
I'm not sure that I completely understand what you are asking, but if you're looking to add a plot to the last string you plotted (and you're using gnuplot 4.4), the following does the trick:
Anyway, I'm not sure if that's what you're asking for as I don't use Matlab, but I hope it is.
不幸的是,在 gnuplot 中绘制单点并不容易,但幸运的是,这里讨论了一些简单的技巧: 使用 Gnuplot 绘制单点。不过,那里讨论的 echo 方法只能在 Unix 环境中工作。
在程序中将其与
replot
而不是plot
结合使用,有望为您提供一个随时间变化的点图,并保留以前的点。另一种方法(我在 python 中使用的方法)是将数据点放入文件中。在每次迭代中,我都会向文件添加点,然后再次使用 gnuplot 进行绘图。它有点难看,但在大多数情况下它都能完成工作。
Unfortunately it's not easy to plot single points in gnuplot, but luckily there are some simple hacks as discussed here: Plotting a Single Point with Gnuplot. The echo method discussed there will only work in a Unix environment though.
Using this with
replot
instead ofplot
in your program should hopefully give you a graph of points evolving with time that preserves the previous points.Another way, which is what I use with python, is that I put the data points in a file. In every iteration, I add points to the file then plot with gnuplot again. It's a little ugly, but it does the job in most cases.