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).