如何在Cnplot中实时绘制图形? [英] How to plot graphs in Gnuplot in Real time in C++?

查看:229
本文介绍了如何在Cnplot中实时绘制图形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用GNUplot和C ++实时绘制图表。
有没有人知道任何好的图书馆这样做?
感谢

I'm trying to plot a graph in real time using GNUplot and C++. Does anyone know of any good libraries that does this? Thanks

推荐答案

gnuplot支持通过管道输入(在窗口上,有一个单独的可执行文件, pgnuplot )。然后你的程序可以向gnuplot发送新命令,例如 replot ,就像直接将它们输入gnuplot接口一样。

gnuplot supports input via pipes (on windows, there's a separate executable for this, pgnuplot). Then your program can send new commands to gnuplot, such as replot, just as if you were typing them into the gnuplot interface directly.

如何设置管道连接并从C ++程序写入管道的发送端因操作系统而异,因此如果您需要更多帮助,则必须告诉我们您正在使用的是什么。

How you set up the pipe connection and write to the sending end of the pipe from your C++ program varies by operating system, so you'll have to tell us what you're using if you want more help.

在Windows上,有 CreatePipe ,然后设置 hStdInput STARTUPINFO 结构的<$ c>元素传递给 CreateProcess 。如果您需要来自 pgnuplot 的状态消息,请与 hStdOutput 匹配

On Windows, there's CreatePipe and then you set the hStdInput element of the STARTUPINFO struct you pass to CreateProcess. Ditto with hStdOutput if you need the status messages from pgnuplot.

在POSIX(Unix,Linux,Mac OSX等)上,您可以使用 popen 作为快速获取单向连接的方式。对于双向,它在Windows上的工作更像: pipe 得到句柄,然后 fork 进程调用 dup2 将stdin和stdout与管道关联,然后 exec 具有 gnuplot 替换子进程,保留您设置的管道。

On POSIX (Unix, Linux, Mac OSX, etc), you can just use popen as the quick way to get a unidirectional connection. For bidirectional, it works more like on Windows: pipe to get handles to the ends, then fork and in the child process call dup2 to associate stdin and stdout with the pipe, then exec to have gnuplot replace the child process, keeping the pipes you set up.

编辑:从 gnuplot文档


特殊文件名' - '指定
数据是内联的;即,它们
遵循命令。只有数据
跟随命令; 情节选项(例如
过滤器,标题和线型)
保留在 plot 命令行中。这个
类似于<<在unix shell脚本中,
和$ DECK在VMS DCL中。输入的数据是
,就像从文件读取
一样,每个
记录一个数据点。在
开头的字母e第一列终止数据
条目。 使用选项可以应用
到这些数据 - 使用它来过滤
他们通过一个函数可能会使
有意义,但选择列可能
't!

The special filename ’-’ specifies that the data are inline; i.e., they follow the command. Only the data follow the command; plot options like filters, titles, and line styles remain on the plot command line. This is similar to << in unix shell script, and $DECK in VMS DCL. The data are entered as though they are being read from a file, one data point per record. The letter "e" at the start of the first column terminates data entry. The using option can be applied to these data — using it to filter them through a function might make sense, but selecting columns probably doesn’t!

这篇关于如何在Cnplot中实时绘制图形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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