|
From: walter h. <wh...@bf...> - 2012-02-19 13:11:03
|
I think what you need is libplot from gnu plot utils, it supports things like animated gifs. see: http://www.gnu.org/software/plotutils/manual/en/html_node/Sample-C-Drawings.html#Sample-C-Drawings re, wh Am 19.02.2012 02:56, schrieb Allan Felipe: > > Hi, I would like to plot a set of points which is being generated by a C > code, using pipe. It would plot a sequence of these points making a video. > Here is an example that does the job: > > ---------------------------------------------------------------- > > #include <stdio.h> > #include <stdlib.h> > #include <unistd.h> > > int main() { > > FILE *pipe; > pipe = popen("gnuplot -persist", "w"); > > fprintf(pipe, "set xlabel 'x (m)' \n"); > fprintf(pipe, "set ylabel 'y (m)' \n"); > fprintf(pipe, "set pointsize 1 \n"); > fprintf(pipe, "set xrange[-0.1:4.1] \n"); > fprintf(pipe, "set yrange[-0.1:4.1] \n"); > > int i; > double x, y; > > for (i = 1; i < 30; i++) { > x = (double) rand() / RAND_MAX; > y = (double) rand() / RAND_MAX; > > fprintf(pipe, "plot '< echo %lf, %lf' w p pt 7 lc -1 notitle \n", > 4*x, 4*y); > > fflush(pipe); > usleep(150000); > } > > fclose(pipe); > return 0; > } > > ------------------------------------------------------------------------------------- > > It works ... however, the way it is done, it plots just one point at a time. > I would like to plot one point, then another one, but keeping the last point > ... then another, keeping all the other 2 ... so I'd like to know how I > could add one point to a graph that is already done, that would solve my > problem. |