开发者

Visualization from C/C++ via Gnuplot's pipe interface

开发者 https://www.devze.com 2022-12-19 00:22 出处:网络
I am attempting to use the pipe interface to gnuplot (a standard one gnuplot_i.{cpp,hpp}) in order to generate a real time display of values that are continually changing within another program writte

I am attempting to use the pipe interface to gnuplot (a standard one gnuplot_i.{cpp,hpp}) in order to generate a real time display of values that are continually changing within another program written in C++. This works ok but I wanted to see if anyone had any suggestions for improvement.

This implementation contains a convenience method to plot a single vector and 2 vectors as a 2D plot. It achieved this by writing out to a temporary file via a standard library call to the mktemp function and then using that as input to a gnuplot plot call. This generated too many temporary files and didn't appear to work well when the update rate on the plot is high (maybe IO limited at a point). I have decided to use the '-' pseudo file in the plot call and just send the vectors directly to the pipe (ended with a single line with "e" on it). This works better but is still not great.

Is there a slicker way to do what I am attempting to do than to continually regenerate the plot when the values have changed? How often is it safe to update the plot with new information? Alternatively, maybe there's a much simpler way to achieve what I am trying to do?

@Andy Ross

I have no "requirements" per se. What I meant by slick was that maybe there was a more elegant approach to doing what I was attempting while still using gnuplot. Although elegant is subjective, I find the approach I am presently taking particularly inelegant. What I meant by safe was whether anyone knew at what update rate there would be IO problems (e.g., latency, lock-up of display, etc.) with said approach.

I'd like to avoid using a toolkit for the following reasons (my short-list at least).

  • I have found that they are generally nontrivial to install properly on different architectures especially as开发者_开发知识库 non-root (and when they require dependencies that aren't standard across OSes).
  • They incur an additional compilation dependency for other people using this software.
  • There doesn't appear to be any real standard that most people use for this purpose afiak (myself as well as most people I work with generally just saves off log type files and does post run analysis in MATLAB).
  • I know/learning gnuplot syntax. I do not know superPlottingApiXX's syntax.
  • The feature set of gnuplot is almost ideal for the types of things I'd like to be able to do with this software.

However, if you have any particular suggestions in terms of C/C++ plotting libraries that seem like a good fit given the above list I am always interested in suggestions (warning: I have already looked around a good bit to find them).


gnuplot-cpp is an object-oriented C++ wrapper interface around a POSIX pipe connection with Gnuplot.

The example file compiled right away and the interfacing code looks decent; I'll be trying it in my current project.


there is a C2gnuplot library I wrote few years ago. It is very simple but may give you some tips. Basically it uses FIFO files to pass data into Gnuplot.It is able to generate animation from the plots. Here is a video created with the app. I hope this will be useful for you.


Slicker? Safe? Can you be more specific about your requirements?

It sounds like you are trying to do an animated visualization with a tool designed for generating static images. If your display is as simple as you say, why not write a quick GUI app (using the toolkit of your choice) to do the drawing instead?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号