Making C code plot a graph automatically

后端 未结 5 2143
离开以前
离开以前 2020-11-30 00:49

I have written a program which writes a list of data to a \'.dat\' file with the intention of then plotting it separately using gnuplot. Is there a way of making my code pl

5条回答
  •  悲哀的现实
    2020-11-30 01:21

    I know it's too late, but answering if it may help someone. fputs really does the job, you want. first you need to print the data you want to plot in a temporary file data.temp.

    FILE *pipe_gp = popen("gnuplot -p", "w");
    fputs("set terminal png \n",pipe_gp);
    fputs("set output 'abc.png' \n",pipe_gp);
    fputs("set xlabel 'f' \n",pipe_gp);
    fputs("set xrange [0:100] \n",pipe_gp);
    fputs("set yrange [0:100] \n",pipe_gp);
    fputs("plot 'data.temp' u 1:2 w circles lc rgb 'pink' notitle \n",pipe_gp);
    pclose(pipe_gp);
    

提交回复
热议问题