Assume that I have some array of data (a vector to be specific).
Can I plot it element by element sequentially using Gnuplot such that it seems as if it is a real life signal that is being traced through a monitor?

I know that I can write the whole data into a text file using Common Lisp, then using gnuplot I can plot it in a batch format. What I require is that I want to put a point on my plot as data comes sequentially.

Data will probably be generated inside a loop, thus you may consider x-axis as the integer valued discrete-time axis. So in the loop if the first element of the array is generated as 5, I would like to put a point on my plot to (0,5). Then if the second element is generated as 3, I would like to put another point on my plot to (1,7) (preserving the old data point). So as I iterate through the loop, I plot the data sequentially.

I am using emacs and Common Lisp for my purposes and I want to plot this data staying within these tools. If there are any other options other than Gnuplot, I would like to hear them.

If this is not easily possible, it would be cool, if I can run a Gnuplot command file by some Common Lisp command.

edit:

Following advices people gave under this thread, I wrote a code using cgn which uses ltk.
Right now I open two x11 windows at pre-specified positions on my screen and I enter the loop. In loop each time I open a stream and write the data (sine and cosine waves of 0.25 Hz sampled at 20 Hz) to the text file trial.txt with the :if-exists :append option and close the stream. Then at each iteration I plot the whole data using the gnuplot through the format-gnuplot command. This code gives me two windows of pre-specified x and y ranges and then one can watch the evolutions of aforementioned sine and cosine waves in the windows.
As I have stated before I don't have strong programming background (I am an electrical engineer who somehow ended using common lisp) and I am pretty sure that my code is non-optimal and unelegant. If you guys have some further advices, corrections etc. I would really like to hear them. The code is here:

So you want an empty window, and then, point after point all your data gets displayed with a delay between displaying point n and point n+1,say a second, am i understanding your question right?
–
Pavel PenevFeb 15 '12 at 18:05

exactly, 1 second or depending on the sampling rate of my data Ts sec.
–
YBEFeb 15 '12 at 18:35

Unless I'm mistaken this has barely nothing to with Emacs, right? For alternative solution, you might consider R, as illustrated on this CV thread. If I can think of a proper solution in CL/gnuplot, I will post it.
–
chlFeb 15 '12 at 20:26

@chl thanks for the reply. the data will be generated in lisp, I know that in R and matlab I can plot dynamically but the issue is that whether I can communicate lisp with any other available plotting tool. If possible, I would like to do all within lisp, but if not I will need to somehow generate the data in lisp and somehow plot it using R, matlab, gnuplot etc.
–
YBEFeb 15 '12 at 20:39

@YBE The problem is to update gnuplot graphical device, not really the binding between CL and gnuplot; I've used cgn in the past, but I'm not aware of dynamic plotting facilities with CL, unless you want to switch to something like xlispstat or Arc (not Paul Graham's Arc); both are based on a subset of CLISP.
–
chlFeb 15 '12 at 20:52

will cgn work dynamically as I asked in the question? Thanks a lot in advance.
–
YBEFeb 16 '12 at 23:37

Yes, definitely. You just need to start-gnuplot, and then you can interactively evaluate different cgn functions
–
Vsevolod DyomkinFeb 17 '12 at 8:23

I have used cgn for plotting yesterday. It works. However I am not sure, how I can achieve the goal of plotting the data dynamically in a equivalent manner to the MATLAB's drawnow function in gnuplot. Do you have any idea? Thanks in advance.
–
YBEFeb 17 '12 at 16:42

I'm not sure about how exactly drawnow works, but as far as I understand the term dynamically, you can do exactly that with cgn. First you start-gnuplot, and then every plotting function you evaluate causes on-the-fly changes to the drawn graph.
–
Vsevolod DyomkinFeb 18 '12 at 7:57

can you please check the code above that I have added.
–
YBEFeb 18 '12 at 18:52

I am not experienced with Gnuplot, and a quick search didn't turn up too much information. But perhaps i can propose an approach. Say you chunk your input, for example '(1 2 3 4 5) would be '((1) (1 2) (1 2 3) (1 2 3 4) (1 2 3 4 5)), you can then generate a plot for each, and use a graphics library like lispbuilder-sdl to display it in a window with a time delay. SDL has a timer and it can display images just fine.