0

I'm trying to plot using Gnuplot in C and so far I'm half succeeding following another thread, but couldn't find anywhere how to go one step beyond.

My code for plotting goes as follows:

char * commandsForGnuplot[] = {"set title \"Probability evolution\"", "plot 'data.temp' with linespoints", "set xlabel \"beta probability\"", "set ylabel \"Fraction of sick individuals\""};
    FILE * temp = fopen("data.temp", "w");
    FILE * gnuplotPipe = popen ("gnuplot -persistent", "w");
    for (i=0; i < NB; i++){
    fprintf(temp, "%lf \n", B[i]); 
    }
    for (i=0; i < 4; i++){
    fprintf(gnuplotPipe, "%s \n", commandsForGnuplot[i]); 
    }

Everything is showed correctly except for the xlabel and ylabel, so this part must be wrong:

"set xlabel \"beta probability\"", "set ylabel \"Fraction of sick individuals\""

Does anyone know how to set it properly?

Also, how can I set the size of these labels and the title?

Thanks a million!

Arduino
  • 373
  • 1
  • 3
  • 21

1 Answers1

0

The plot part is what actually creates the plot. Everything you set afterwards, is ignored:

char * commandsForGnuplot[] = {
    "set title \"Probability evolution\"", 
    "set xlabel \"beta probability\"",
    "set ylabel \"Fraction of sick individuals\"",
    "plot 'data.temp' with linespoints"
};
Christoph
  • 47,569
  • 8
  • 87
  • 187