Note that there are some explanatory texts on larger screens.

plurals
  1. POhide C++ Gnuplot pipe console output
    primarykey
    data
    text
    <p>In <code>C++</code>I'm currently using this bit of code to plot some data using <code>gnuplot</code>. <code>Gnuplot</code>'s <code>fit</code> command, however, produces a lot of unwanted output on the command line console (which I use for outputting some other stuff too, throughout the rest of my program). </p> <p>Since this output clutters up my console output, I would like to disable it. There should be 2 ways to do this:</p> <ol> <li>Hide output created by external programs using <code>pipe</code> in <code>C++</code></li> <li>Telling <code>gnuplot</code> to be silent and not output that much</li> </ol> <p><code>FILE *pipe = popen("gnuplot -persist", "w");//open up a pipe to gnuplot</code></p> <pre><code>fprintf(pipe, "set terminal x11 enhanced\n"); //set appropriate output terminal for the plot fprintf(pipe, "set xlabel 'N'\n");//set xlabel fprintf(pipe, "set ylabel 'error'\n");//set ylabel fprintf(pipe, "set yrange [0:0.0001]\n");//set the y range fprintf(pipe, "plot 'dataSimp.dat' ti 'Simpson method'\n");//plot the Simp error fprintf(pipe, "replot 'dataTrap.dat' ti 'Trapezium method' \n");//plot the Trap error fprintf(pipe, "replot 1/(x**2) ti '1/{x^2}'\n");//plot y=1/(x^2) function for comparison fprintf(pipe, "replot 1/(x**4) ti '1/{x^4}'\n");//plot y=1/(x^4) function for comparison //fit curve to dataSimp fprintf(pipe, "set output 'rommel.txt'"); fprintf(pipe, "fSimp(x)=aSimp/(x**4) \n"); fprintf(pipe, "fit fSimp(x) 'dataSimp.dat' via aSimp\n"); fprintf(pipe, "replot aSimp/(x**4) ti 'fitted aSimp/{x^4}'\n"); //fit curve to dataSimp fprintf(pipe, "fTrap(x)=aTrap/(x**2) \n"); fprintf(pipe, "fit fTrap(x) 'dataTrap.dat' via aTrap \n"); fprintf(pipe, "replot aTrap/(x**2) ti 'fitted aTrap/{x^2}'\n"); pclose(pipe);//close gnuplot pipe </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload