0

I wrote a computer simulation program (the details are irrelevant) that writes on two files some results in a 2 colums format, then i used gnuplot from another terminal to plot these results on a graph, successfully. Now i want to integrate the graph with the program, so that i don't have to run gnuplot from another terminal. so

/*while loop that writes data on the 2 files, the data is consistent as the graphs are good running gnuplot from a separate terminal
*/

fclose(file_wait);
fclose(file_discarted);

system("gnuplot -p -e \"plot 'wait.dat'\"");
system("gnuplot -p -e \"plot 'discarted.dat'\"");

The funny thing is that this program work when the file has less than 1000 lines (the full data set is 2600 lines) more that that and the program terminates but the grapsh aren't visualized.

7
  • 2
    Use popen() there is an example here. Your program will not work because you need to exit the first window to plot the second file, so write a gnuplot script instead. Commented Feb 9, 2015 at 14:11
  • Actually when the data sets are less then 1000 lines it plot both graphs opening 2 windows. I tryed with only one file too, same situation. Commented Feb 9, 2015 at 14:17
  • 1
    did you try the suggested popen() method? Commented Feb 9, 2015 at 14:27
  • Nope, it doesn't work FILE * gnuplotPipe = popen ("gnuplot", "w"); returns NULL Commented Feb 9, 2015 at 18:07
  • sure it does, try FILE * gnuplotPipe = popen ("gnuplot", "r"); Commented Feb 9, 2015 at 18:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.