home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / graphics / gnuplot / 299 < prev    next >
Encoding:
Text File  |  1992-11-06  |  2.6 KB  |  67 lines

  1. Newsgroups: comp.graphics.gnuplot
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!elroy.jpl.nasa.gov!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!ux2.cso.uiuc.edu!ejk
  3. From: ejk@ux2.cso.uiuc.edu (Ed Kubaitis - CCSO)
  4. Subject: Re: GNUPLOT An Interactive Plotting Program v.3.2
  5. References:  <16090.9211051705@SunLab41.essex.ac.uk>
  6. Message-ID: <Bx9ADF.BuK@news.cso.uiuc.edu>
  7. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  8. Organization: University of Illinois - Urbana
  9. Date: Thu, 5 Nov 1992 18:36:49 GMT
  10. Lines: 55
  11.  
  12. oakli@essex.ac.uk (Oakley I G) writes:
  13.  |I have taken the above email address from the cover of the GNUPLOT 3.2 manual
  14.  |in the hope that the recipiant can help me.
  15.  |
  16.  |As part of my final year project here at Essex University, U.K. I am intending
  17.  |on using Gnuplot to display various data that my 'C' program will produce.
  18.  |
  19.  |What I would like to be able to do is execute Gnuplot from within my 'C' code
  20.  |so that it can be used as an interactive part of the program bringing up a
  21.  |Gnuplot window displaying any data set chosen by the user.
  22.  |
  23.  |I am currently not sure if this is possible although I have a few basic ideas)
  24.  |so I would appreciate you telling me how to go about doing it (with some 
  25.  |example code maybe).  I know there is a library routine system() which allows
  26.  |commands to be executed as if they were typed from the shell.  When using 
  27.  |this command and piping in a datafile, the Gnuplot window only appears 
  28.  |very briefly despite the use of 'pause -1' in the datafile.
  29.  |
  30.  |I am currently using SUN SPARCstations running an X-window environment with
  31.  |the UNIX operating system.
  32.  
  33. Not sure what you mean by "piping in a datafile", but attached is a very
  34. simple example of calling gnuplot from a c program. Perhaps it will
  35. help. In this example, 'pause -1' seems to work as you want.
  36.  
  37. ----------------------------------
  38. Ed Kubaitis (ejk@ux2.cso.uiuc.edu)
  39. Computing & Communications Services Office - University of Illinois, Urbana
  40. ===============================================================================
  41. #include <stdio.h>
  42.  
  43. FILE *commands, *data;
  44.  
  45. main(argc, argv) int argc; char *argv[]; {
  46.  
  47.    data = fopen("/tmp/gp.data", "w");
  48.    fprintf(data, "1 1\n");
  49.    fprintf(data, "2 2\n");
  50.    fprintf(data, "3 3\n");
  51.    fprintf(data, "4 4\n");
  52.    fclose(data);
  53.  
  54.    commands = fopen("/tmp/gp.commands", "w");
  55.    fprintf(commands, "set term x11\n");
  56.    fprintf(commands, "plot '/tmp/gp.data' with line 1\n");
  57.    fprintf(commands, "pause -1 'Hit return'\n");
  58.    fclose(commands);
  59.  
  60.    system("gnuplot /tmp/gp.commands");
  61.  
  62.    unlink("/tmp/gp.commands");
  63.    unlink("/tmp/gp.data");
  64.    exit(0);
  65.  
  66.    }
  67.