Countinous Plotting

Countinous Plotting

Post by Loren M. L » Fri, 18 Jun 2004 16:50:05

I'm looking for a way to be able to show a continuously running graph of a
live test I will be running. I have been using gnuplot controlled from a
perl script to graph the data of test both during and after. During a test
I am constantly storing data to a file and then, every two seconds and have
the gnuplot X axis set to the last 60 seconds and it has worked out nicely.
Gnuplot has done a fine job with all of it's features, but now that we will
he demoing our unit at a trade show and they want to be able to show a
continuously running graph of the test without the jerk that my approach
puts into it. Is there anyway to achieve this with gnuplot currently, or
does anyone know of another plotting program for unix that will help me
achieve this?

I can try and have gnuplot plot the graphs as fast as achiever instead of
sticking a 2 second delay, but I haven't tried this yet and am not sure if
it will yield the right results. The other problem I realize will the data
files getting too large and slowing the plotting speed. This can be fixed
by me re-writing my perl script to create a new plot file every 60+ seconds,
and overlap each one by at least 60 seconds so it will go unnoticed, but it
doesn't sound like the best approach.

My last question is that I would like to embed the graphs inside of an
another window with various buttons and menus to control the test and watch
how the unit responds. I might be writing the gui in perl/tk or perl/gtk.
I've seen how konqueror can embed various apps into it's file manager like
kmplayer, is this a standard thing to be able to do, maybe even the same
kind of thing that a wm does to surround a window with a frame?

Countinous Plotting

Post by Hans-Bernh » Fri, 18 Jun 2004 22:00:39

gnuplot isn't exactly very good at this job, which is often referred
to as "real-time plotting". You can fake it by replotting in a tight
loop, under external control, but that's not a very robust solution.

One further idea to consider is that if you can use inline data in
the command stream instead of an external data file, avoiding the need
to recycle.

As to the jerkyness: that'll be reduced quite a lot if you make the
ratio of axis length to redraw interval larger. 60 seconds versus 2
seconds means the plot will jump by 3 percent of its width on each
replot. Make the axis longer (3 minutes, say, or even more), and
redraw more often, and it'll be far less apparent. For simple
diagrams on a local display, gnuplot can do dozens of plots per
second. But it'll flicker like heck --- gnuplot isn't designed for
that kind of animation.

Hans-Bernhard Broeker ( XXXX@XXXXX.COM )
Even if all the snow were burnt, ashes would remain.


Countinous Plotting

Post by thopma » Fri, 18 Jun 2004 23:07:55

The "jerk" you speak of is likely the screen area being cleared before
being redrawn. As far as I know, this can't be avoided, at least not
using the x11 terminal. If you want, you could get your hands dirty
and add double-buffering, where the graph is first drawn on an bitmap,
then blitted to the screen, rather than directly onto the screen.

A shorter period between plots will result only in more rapid
flickering. As for the slower plotting with longer data files, well,
that's the nature of taking data from the end of files without a
well-defined record length. A possible solution: since gnuplot is
being controlled by a (continuously running) perl script, why not keep
the last 60 seconds of data in an array in your script, then plot
using inline data, where gnuplot looks for data from stdin? See `help
special-filenames` for details.

I've never done anything like this. That said, you could use the
`tkcanvas` terminal to generate Tk canvas widget commands. Or you
could have gnuplot plot to a bitmap file using (e.g.) the `png`
terminal, which file you GUI might then be able to display. Both of
these solutions, I think, effectively implement double-buffering, so
you get rid of the "jerk" as well.