There is an example of an animation that comes with the gnuplot-iostream library. It doesn't flicker, at least not on my machine (Linux). Disclaimer: I'm the author of that library, so that is a shameless plug.
Your code snippet doesn't show how you actually interface with gnuplot, however there are three things you must be sure to do: 1) don't close and then reopen the pipe after each frame, 2) call fflush
on the pipe after every frame, and 3) add a delay between frames. To delay on Linux call ::usleep(microseconds)
(and include unistd.h
), on Windows call ::Sleep(milliseconds)
and include windows.h
.
The thing about piping animation data to gnuplot is that you don't know if it is keeping up. So the flush and the sleep are vital. But I have built an oscilloscope out of gnuplot so I know it can work well.