Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #202

Re: How to re-use the same output device/xterm each time gnuplot is invoked?

From James Waldby <not@valid.invalid>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: How to re-use the same output device/xterm each time gnuplot is invoked?
Date 2011-04-01 16:41 +0000
Organization A noiseless patient Spider
Message-ID <in4v7p$g5g$9@dont-email.me> (permalink)
References <in3j2j$og8$1@speranza.aioe.org>

Show all headers | View raw


On Thu, 31 Mar 2011 21:07:46 -0700, Nasser M. Abbasi wrote:
...
> I am on linux, and I am very new to gnuplot, but I am trying to see if I
> can use it to make animation by calling it from Fortran program.
> 
> The setup is like this:
>    PROGRAM ----> gnuplot
> 
> Where the actual call inside the program follow this logic
> 
> LOOP
>     -- update data, create new data.txt file on disk  from this data
>     CALL system('gnuplot batch.plt')  -- call to make new plot
> END LOOP
> 
> and batch.plt would start as
> 
> #!/usr/bin/gnuplot -persist
> ... load data from data.txt  and make plot # EOF
> 
> The above works OK, but the problem is that each call makes a NEW xterm
> on top of the earlier one.
...

Since you have a system() function, perhaps you also have a 
popen() function available.  In C, one would use (eg)
   FILE *f = popen("/usr/bin/gnuplot", "w");
   if (!f) exit(1);   /* exit if error */
to open a pipe to gnuplot standard input, and thereafter use
   fprintf (f, ...);
   ...
   fflush (f);
to write data to gnuplot, such as "plot '-'" commands and
data sequences.

See eg <http://linux.die.net/man/3/popen> and 
<http://bama.ua.edu/cgi-bin/man-cgi?popen+3C>

-- 
jiw

Back to comp.graphics.apps.gnuplot | Previous | NextPrevious in thread | Find similar


Thread

How to re-use the same output device/xterm each time gnuplot is invoked? "Nasser M. Abbasi" <nma@12000.org> - 2011-03-31 21:07 -0700
  Re: How to re-use the same output device/xterm each time gnuplot is invoked? geep <geep@boursomail.com> - 2011-04-01 15:09 +0000
    Re: How to re-use the same output device/xterm each time gnuplot is invoked? sfeam <sfeam@users.sourceforge.net> - 2011-04-01 10:54 -0700
  Re: How to re-use the same output device/xterm each time gnuplot is invoked? James Waldby <not@valid.invalid> - 2011-04-01 16:41 +0000

csiph-web