For a terminal application written in C I need to plot (in the terminal) two tables as line plots. To do this I use (following e.g. gnu tutorial)
FILE *gnuplot = popen("gnuplot", "w");
...
fprintf(gnuplot, "plot '-' u 1:2 t 'data1' w lp lt 0\n");
for (int i = 0; i < lines; ++i) {
fprintf(gnuplot,"%f %f \n", x[i] - x[0], y[i]);
}
fprintf(gnuplot, "\n");
fprintf(gnuplot, "t 'data2' lt 2\n");
for (int i = 0; i < lines; ++i) {
fprintf(gnuplot,"%f %f \n", x[i] - x[0], 0.4*(x[i] - c0)/c1);
}
fprintf(gnuplot, "e\n");
fflush(gnuplot);
The problem is that the data is plotted as one data block instead of two different ones. I expected to have a separation by using the line
fprintf(gnuplot, "t 'data2' lt 2\n");
which seems not to be the case. What is wrong in this code?