How to plot data by c program?

前端 未结 6 1926
攒了一身酷
攒了一身酷 2020-12-24 12:40

I am a mechanical engineer who has only limited knowledge in C programming. I wrote some code in order to make simulations, and I want to visualize the simulation results. A

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-24 13:42

    Since you already know gnuplot, the simplest thing to do may be to just call gnuplot from your program and pipe the data to it:

    FILE *gnuplot = popen("gnuplot", "w");
    fprintf(gnuplot, "plot '-'\n");
    for (i = 0; i < count; i++)
        fprintf(gnuplot, "%g %g\n", x[i], y[i]);
    fprintf(gnuplot, "e\n");
    fflush(gnuplot);
    

提交回复
热议问题