I have a pipe to gnuplot which I use to graph a file. The file gets graphed fine and is produced on the screen, however when I try to pipe set terminal jpeg and set output file.jpeg I get garbage on the screen. Has any one else had the same problem. Here is the code:
FILE *gnuplotPipe = popen("gnuplot -persist","w");
fprintf(gnuplotPipe, "set terminal jpeg\n"); //without these two lines it works
fprintf(gnuplotPipe, "set output %s.jpeg\n ",fileName);
int i = 2;
if (gnuplotPipe)
{
fprintf(gnuplotPipe, "plot ");
....//plot some stuff,it is tested works.
}
fprintf(gnuplotPipe, "\n");
fflush(gnuplotPipe);
fprintf(gnuplotPipe,"exit \n");
pclose(gnuplotPipe);
}
I also tried flushing after the two commands but at no results.
You need to enclose the file name in quotes like: