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
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- How to set a variable line width when plotting?
- thread_local variables initialization
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
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 asreplot
, just as if you were typing them into the gnuplot interface directly.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.
On Windows, there's
CreatePipe
and then you set thehStdInput
element of theSTARTUPINFO
struct you pass toCreateProcess
. Ditto withhStdOutput
if you need the status messages frompgnuplot
.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, thenfork
and in the child process calldup2
to associate stdin and stdout with the pipe, thenexec
to havegnuplot
replace the child process, keeping the pipes you set up.EDIT: From the gnuplot documentation:
If you're interested in soft-realtime plotting, you're probably best of using a hardware accelerated graphics api (such as OpenGL), and plotting the chart yourself.
Have you tried gnuplot interfaces in ANSI C?, this is an interface for C but in the same links there are some interface for C++. Or you could try PlPlot.
Look at http://search.cpan.org/~dkogan/feedGnuplot-1.08/bin/feedGnuplot This is a commandline utility, but also works well if controlled from a program.
In my C++ code, this worked (on mac OsX mavericks, using g++ Apple LLVM version 5.0):